summaryrefslogtreecommitdiff
path: root/reconfigure/tests/includers
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
committerAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
commitff1408420159488a106492ccd11dd234967029b6 (patch)
tree473420cee1c5229a427ec4cafead1aa6c0a26800 /reconfigure/tests/includers
Imported Upstream version 0.1.29
Diffstat (limited to 'reconfigure/tests/includers')
-rw-r--r--reconfigure/tests/includers/__init__.py0
-rw-r--r--reconfigure/tests/includers/nginx_tests.py29
2 files changed, 29 insertions, 0 deletions
diff --git a/reconfigure/tests/includers/__init__.py b/reconfigure/tests/includers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/reconfigure/tests/includers/__init__.py
diff --git a/reconfigure/tests/includers/nginx_tests.py b/reconfigure/tests/includers/nginx_tests.py
new file mode 100644
index 0000000..ad980a1
--- /dev/null
+++ b/reconfigure/tests/includers/nginx_tests.py
@@ -0,0 +1,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')