summaryrefslogtreecommitdiffstats
path: root/tests/format.py
blob: 8ddce9b47efb34222de4e095221a43b008347c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: UTF-8 -*-
# Copyright 2013 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2 (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""Testing format"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"

import unittest
from os.path import dirname, join
#from pprint import pprint

import _bootstrap  # known W402, required

from clufter.formats.ccs import ccs

WALK_DIR = join(dirname(__file__), 'XMLFormat-walk')

RESULT_WALK_FULL = {
    'cluster': ('cluster-full', {
        'clusternodes': ('clusternodes-full', {
            'clusternode': ('clusternode-full', {
            })
        }),
        'cman': ('cman-full', {
        }),
        'dlm': ('dlm-full', {
        }),
        'rm': ('rm-full', {
            'failoverdomains': ('failoverdomains-full', {
                'failoverdomain': ('failoverdomain-full', {
                })
            }),
            'service': ('service-full', {
            })
        })
    })
}

RESULT_WALK_SPARSE = {
    'failoverdomain': ('failoverdomain-sparse', {
    }),
    'heuristic': ('heuristic-sparse', {
    })
}


class XMLFormatWalkTestCase(unittest.TestCase):
    def testWalkFull(self):
        r = ccs.walk_schema(WALK_DIR, 'full')
        #pprint(r, width=8)  # --> expected
        self.assertTrue(r == RESULT_WALK_FULL)

    def testWalkSparse(self):
        r = ccs.walk_schema(WALK_DIR, 'sparse')
        #pprint(r, width=8)  # --> expected
        self.assertTrue(r == RESULT_WALK_SPARSE)


if __name__ == '__main__':
    unittest.main()