def test_dumps_and_loads_configuration_hierarchy_with_data(self): root = api.Configuration("root.confml") layer = api.Configuration("layer1") conf = api.Configuration("test") conf.add_feature(api.Feature("feature1")) conf.add_feature(api.Feature("feature2")) conf.feature1.add_feature(api.Feature("feature11")) conf.feature1.add_feature(api.Feature("feature12")) conf.feature1.set_value(1) conf.feature2.set_value(2) layer.add_configuration(conf) root.add_configuration(layer) root.add_configuration(api.Configuration("layer2")) root.get_default_view().feature1.feature11.set_value("testing11") root.get_default_view().feature1.set_value("test1") dumped = persistentdictionary.DictWriter().dumps(root) root2 = persistentdictionary.DictReader().loads(dumped) self.assertEquals(root.list_all_features(), root2.list_all_features()) self.assertEquals(root2.get_default_view().feature1.get_value(), "test1") self.assertEquals(root2.get_default_view().feature2.get_value(), 2) self.assertEquals( root2.get_default_view().feature1.feature11.get_value(), "testing11") self.assertEquals([ data.find_parent(type=api.Configuration).get_path() for data in root2.get_all_datas() ], ['test', 'test', 'layer2', 'layer2'])
def test_dumps_and_loads(self): conf = api.Configuration("test.confml") conf.add_feature(api.Feature("feature1")) conf.add_feature(api.Feature("feature2")) conf.feature1.add_feature(api.Feature("feature11")) conf.feature1.add_feature(api.Feature("feature12")) dumped = persistentdictionary.DictWriter().dumps(conf) conf2 = persistentdictionary.DictReader().loads(dumped) self.assertEquals(conf.list_all_features(), conf2.list_all_features())
def test_loads(self): conf = persistentdictionary.DictReader().loads({ 'Configuration': { 'dict': { 'namespace': 'test', 'ref': 'test.confml' } } }) self.assertTrue(isinstance(conf, api.Configuration)) self.assertEquals(conf.namespace, 'test') self.assertEquals(conf.get_ref(), 'test.confml')
def test_dumps_and_loads_configuration_hierarchy(self): root = api.Configuration("root.confml") root.add_configuration(api.Configuration("layer1")) layer = api.Configuration("layer2") conf = api.Configuration("test") conf.add_feature(api.Feature("feature1")) conf.add_feature(api.Feature("feature2")) conf.feature1.add_feature(api.Feature("feature11")) conf.feature1.add_feature(api.Feature("feature12")) layer.add_configuration(conf) root.add_configuration(layer) dumped = persistentdictionary.DictWriter().dumps(root) root2 = persistentdictionary.DictReader().loads(dumped) self.assertEquals(root.list_all_features(), root2.list_all_features())
def test_loads_with_features(self): root = api.Configuration("root", namespace="com.nokia") conf = persistentdictionary.DictReader().loads({ 'Configuration': { 'dict': { 'namespace': 'test', 'ref': 'test.confml' }, 'children': [{ 'Feature': { 'dict': { 'ref': 'feature1' }, 'children': [{ 'Feature': { 'dict': { 'ref': 'feature11' } } }, { 'Feature': { 'dict': { 'ref': 'feature12' } } }] } }, { 'Feature': { 'dict': { 'ref': 'feature2' } } }] } }) self.assertEquals(conf.namespace, 'test') self.assertEquals(conf.ref, 'test.confml') root.add_configuration(conf) self.assertEquals(root.list_all_features(), [ 'test.feature1', 'test.feature1.feature11', 'test.feature1.feature12', 'test.feature2' ])