diff --git a/cdist/test/cdist_object/__init__.py b/cdist/test/cdist_object/__init__.py index 70506da4..ffb2ba79 100644 --- a/cdist/test/cdist_object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -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): diff --git a/cdist/test/cdist_object/fixtures/type/__test_singleton/singleton b/cdist/test/cdist_object/fixtures/type/__test_singleton/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index 5645e73c..ec0d7ae4 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -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' diff --git a/cdist/test/emulator/fixtures/conf/type/__test_singleton/singleton b/cdist/test/emulator/fixtures/conf/type/__test_singleton/singleton new file mode 100644 index 00000000..e69de29b