From 717e21da6c6a93fa77c3da65641b217718d464bd Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Fri, 7 Feb 2014 00:28:02 +0100 Subject: [PATCH] initial update for override unittests --- cdist/test/emulator/__init__.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index 8c2dcd72..d2bf4cf2 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -100,6 +100,7 @@ class EmulatorTestCase(test.CdistTestCase): argv = ['__file', '/tmp/foobar'] self.env['require'] = '__file/etc/*' emu = emulator.Emulator(argv, env=self.env) + emu.run() # if we get here all is fine @@ -129,6 +130,33 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase): expected = ['__planet/Saturn', '__moon/Prometheus'] self.assertEqual(sorted(cdist_object.autorequire), sorted(expected)) +class OverrideTestCase(test.CdistTestCase): + + def setUp(self): + self.temp_dir = self.mkdtemp() + handle, self.script = self.mkstemp(dir=self.temp_dir) + os.close(handle) + base_path = self.temp_dir + + self.local = local.Local( + target_host=self.target_host, + base_path=base_path, + exec_path=test.cdist_exec_path, + add_conf_dirs=[conf_dir]) + self.local.create_files_dirs() + + self.manifest = core.Manifest(self.target_host, self.local) + self.env = self.manifest.env_initial_manifest(self.script) + + def tearDown(self): + shutil.rmtree(self.temp_dir) + + def test_override(self): + argv = ['__file', '/tmp/foobar'] + self.env['require'] = '__file/etc/*' + emu = emulator.Emulator(argv, env=self.env) + # if we get here all is fine + class ArgumentsTestCase(test.CdistTestCase): @@ -182,7 +210,7 @@ class ArgumentsTestCase(test.CdistTestCase): object_id = 'some-id' value = 'some value' argv = [type_name, object_id, '--required1', value, '--required2', value] - print(self.env) +# print(self.env) os.environ.update(self.env) emu = emulator.Emulator(argv) emu.run()