more tests for different ways to access object.explorers
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								9c04da1d42
							
						
					
				
			
			
				commit
				
					
						1b7ebc5885
					
				
			
		
					 1 changed files with 18 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue