From 1b7ebc5885ce9f58466da7d48dbb7ef2465af3cf Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 13 Oct 2011 21:23:04 +0200 Subject: [PATCH] more tests for different ways to access object.explorers Signed-off-by: Steven Armstrong --- lib/cdist/test/object/__init__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/cdist/test/object/__init__.py b/lib/cdist/test/object/__init__.py index 0953027b..982784f2 100644 --- a/lib/cdist/test/object/__init__.py +++ b/lib/cdist/test/object/__init__.py @@ -97,10 +97,27 @@ class ObjectTestCase(unittest.TestCase): def test_explorers(self): self.assertEqual(self.cdist_object.explorers, {}) - def test_explorers_after_changing(self): + # FIXME: actually testing fsproperty.DirectoryDictProperty here, move to their own test case + def test_explorers_assign_dict(self): expected = {'first': 'foo', 'second': 'bar'} # when set, written to file self.cdist_object.explorers = expected + object_explorer_path = os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path) + self.assertTrue(os.path.isdir(object_explorer_path)) + # when accessed, read from file + self.assertEqual(self.cdist_object.explorers, expected) + # remove dynamically created folder + self.cdist_object.explorers = {} + os.rmdir(os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path)) + + # FIXME: actually testing fsproperty.DirectoryDictProperty here, move to their own test case + def test_explorers_assign_key_value(self): + expected = {'first': 'foo', 'second': 'bar'} + object_explorer_path = os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path) + for key,value in expected.items(): + # when set, written to file + self.cdist_object.explorers[key] = value + self.assertTrue(os.path.isfile(os.path.join(object_explorer_path, key))) # when accessed, read from file self.assertEqual(self.cdist_object.explorers, expected) # remove dynamically created folder