summaryrefslogtreecommitdiff
path: root/reconfigure/tests/configs/base_test.py
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/configs/base_test.py
Imported Upstream version 0.1.29
Diffstat (limited to 'reconfigure/tests/configs/base_test.py')
-rw-r--r--reconfigure/tests/configs/base_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/reconfigure/tests/configs/base_test.py b/reconfigure/tests/configs/base_test.py
new file mode 100644
index 0000000..1824819
--- /dev/null
+++ b/reconfigure/tests/configs/base_test.py
@@ -0,0 +1,37 @@
+import unittest
+import json
+
+
+class BaseConfigTest (unittest.TestCase):
+ sources = ""
+ result = None
+ config = None
+ config_kwargs = {}
+ stringify_filter = staticmethod(lambda x: x.split())
+
+ def test_config(self):
+ if not self.config:
+ return
+
+ self.maxDiff = None
+
+ config = self.config(content=self.sources[None], **self.config_kwargs)
+ if config.includer:
+ config.includer.content_map = self.sources
+ config.load()
+ #print 'RESULT', config.tree.to_dict()
+ #print 'SOURCE', self.__class__.result
+ #self.assertTrue(self.__class__.result== config.tree.to_dict())
+ a, b = self.__class__.result, config.tree.to_dict()
+ if a != b:
+ print 'SOURCE: %s\nGENERATED: %s\n' % (json.dumps(a, indent=4), json.dumps(b, indent=4))
+ self.assertEquals(a, b)
+
+ result = config.save()
+ s_filter = self.__class__.stringify_filter
+ #print s_filter(result[None])
+ for k, v in result.iteritems():
+ self.assertEquals(
+ s_filter(self.__class__.sources[k]),
+ s_filter(v)
+ )