enhance singleton testing

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-07-10 17:21:38 +02:00
parent 8ab760ad90
commit c1441fc676
4 changed files with 17 additions and 0 deletions

View file

@ -64,6 +64,16 @@ class ObjectClassTestCase(test.CdistTestCase):
found_objects = list(core.CdistObject.list_objects(object_base_path, type_base_path)) found_objects = list(core.CdistObject.list_objects(object_base_path, type_base_path))
self.assertEqual(found_objects, self.expected_objects) 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): class ObjectIdTestCase(test.CdistTestCase):
def test_object_id_contains_double_slash(self): def test_object_id_contains_double_slash(self):

View file

@ -83,6 +83,13 @@ class EmulatorTestCase(test.CdistTestCase):
emu = emulator.Emulator(argv, env=self.env) emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.cdist_object.MissingObjectIdError, emu.run) 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): def test_singleton_object_requirement(self):
argv = ['__file', '/tmp/foobar'] argv = ['__file', '/tmp/foobar']
self.env['require'] = '__issue' self.env['require'] = '__issue'