enhance singleton testing
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
		
					parent
					
						
							
								8ab760ad90
							
						
					
				
			
			
				commit
				
					
						c1441fc676
					
				
			
		
					 4 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -64,6 +64,16 @@ class ObjectClassTestCase(test.CdistTestCase):
 | 
			
		|||
        found_objects = list(core.CdistObject.list_objects(object_base_path, type_base_path))
 | 
			
		||||
        self.assertEqual(found_objects, self.expected_objects)
 | 
			
		||||
 | 
			
		||||
    def test_create_singleton(self):
 | 
			
		||||
        """Check whether creating an object without id (singleton) works"""
 | 
			
		||||
        singleton = self.expected_objects[0].object_from_name("__test_singleton")
 | 
			
		||||
        # came here - everything fine
 | 
			
		||||
 | 
			
		||||
    def test_create_singleton_not_singleton_type(self):
 | 
			
		||||
        """try to create an object of a type that is not a singleton
 | 
			
		||||
           without an object id"""
 | 
			
		||||
        with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError):
 | 
			
		||||
            self.expected_objects[0].object_from_name("__first")
 | 
			
		||||
 | 
			
		||||
class ObjectIdTestCase(test.CdistTestCase):
 | 
			
		||||
    def test_object_id_contains_double_slash(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,6 +83,13 @@ class EmulatorTestCase(test.CdistTestCase):
 | 
			
		|||
        emu = emulator.Emulator(argv, env=self.env)
 | 
			
		||||
        self.assertRaises(core.cdist_object.MissingObjectIdError, emu.run)
 | 
			
		||||
 | 
			
		||||
    def test_no_singleton_no_requirement(self):
 | 
			
		||||
        argv = ['__file', '/tmp/foobar']
 | 
			
		||||
        self.env['require'] = '__test_singleton'
 | 
			
		||||
        emu = emulator.Emulator(argv, env=self.env)
 | 
			
		||||
        emu.run()
 | 
			
		||||
        # If reached here, everything is fine
 | 
			
		||||
 | 
			
		||||
    def test_singleton_object_requirement(self):
 | 
			
		||||
        argv = ['__file', '/tmp/foobar']
 | 
			
		||||
        self.env['require'] = '__issue'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue