File: nginx_tests.py

package info (click to toggle)
python-reconfigure 0.1.74%2Bgit49a20890-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 724 kB
  • ctags: 701
  • sloc: python: 4,201; makefile: 186; sh: 7
file content (29 lines) | stat: -rw-r--r-- 828 bytes parent folder | download | duplicates (3)
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
#coding: utf8
import unittest
from reconfigure.parsers import NginxParser
from reconfigure.includers import NginxIncluder


class IncludersTest (unittest.TestCase):
    def test_compose_decompose(self):
        content = """
            sec1 {
                p1 1;
                include test;
            }
        """
        content2 = """
            sec2 {
                p2 2;
            }
        """

        parser = NginxParser()
        includer = NginxIncluder(parser=parser, content_map={'test': content2})
        tree = parser.parse(content)
        tree = includer.compose(None, tree)
        self.assertTrue(len(tree.children[0].children) == 3)

        treemap = includer.decompose(tree)
        self.assertTrue(len(treemap.keys()) == 2)
        self.assertTrue(treemap['test'].children[0].name == 'sec2')