From ae8040536f85c3fee1ddfcbcd27d4ac71a0c658f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 15 May 2013 09:26:48 +0200 Subject: [PATCH] mere tests of autorequire and resolver into execution_order Signed-off-by: Nico Schottelius --- cdist/test/autorequire/__init__.py | 91 ------------------- .../{resolver => execution_order}/__init__.py | 91 +++++++++++++++++++ .../fixtures/conf/explorer/.keep | 0 .../conf/manifest/circular_dependency | 0 .../conf/manifest/implicit_dependencies | 0 .../fixtures/conf/manifest/recursive_type | 0 .../conf/type/__addifnosuchline/.keep | 0 .../fixtures/conf/type/__directory/.keep | 0 .../fixtures/conf/type/__git/manifest | 0 .../conf/type/__nfsroot_client/manifest | 0 .../fixtures/conf/type/__package/manifest | 0 .../conf/type/__package_special/.keep | 0 .../type/__root_ssh_authorized_key/manifest | 0 .../fixtures/conf/type/__top/manifest | 0 .../fixtures/conf/type/__user/.keep | 0 .../fixtures/object/__first/.keep | 0 .../object/__first/child/.cdist/.keep | 0 .../fixtures/object/__first/dog/.cdist/.keep | 0 .../fixtures/object/__first/man/.cdist/.keep | 0 .../object/__first/woman/.cdist/.keep | 0 .../fixtures/object/__second/.keep | 0 .../object/__second/on-the/.cdist/.keep | 0 .../object/__second/under-the/.cdist/.keep | 0 .../fixtures/object/__third/.keep | 0 .../fixtures/object/__third/moon/.cdist/.keep | 0 .../object/__third/moon/.cdist/parameter/name | 0 .../__third/moon/.cdist/parameter/planet | 0 .../fixtures/type/__first/.keep | 0 .../fixtures/type/__second/.keep | 0 .../fixtures/type/__third/.keep | 0 30 files changed, 91 insertions(+), 91 deletions(-) delete mode 100644 cdist/test/autorequire/__init__.py rename cdist/test/{resolver => execution_order}/__init__.py (51%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/explorer/.keep (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/manifest/circular_dependency (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/manifest/implicit_dependencies (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/manifest/recursive_type (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__addifnosuchline/.keep (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__directory/.keep (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__git/manifest (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__nfsroot_client/manifest (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__package/manifest (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__package_special/.keep (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__root_ssh_authorized_key/manifest (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__top/manifest (100%) rename cdist/test/{autorequire => execution_order}/fixtures/conf/type/__user/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__first/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__first/child/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__first/dog/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__first/man/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__first/woman/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__second/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__second/on-the/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__second/under-the/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__third/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__third/moon/.cdist/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__third/moon/.cdist/parameter/name (100%) rename cdist/test/{resolver => execution_order}/fixtures/object/__third/moon/.cdist/parameter/planet (100%) rename cdist/test/{resolver => execution_order}/fixtures/type/__first/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/type/__second/.keep (100%) rename cdist/test/{resolver => execution_order}/fixtures/type/__third/.keep (100%) diff --git a/cdist/test/autorequire/__init__.py b/cdist/test/autorequire/__init__.py deleted file mode 100644 index 714a7d4b..00000000 --- a/cdist/test/autorequire/__init__.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -import os -import shutil - -import cdist -from cdist import test -from cdist.exec import local -from cdist import core -from cdist.core import manifest -from cdist import resolver -from cdist import config -import cdist.context - -import os.path as op -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -add_conf_dir = op.join(fixtures, 'conf') - -class AutorequireTestCase(test.CdistTestCase): - - def setUp(self): - self.orig_environ = os.environ - os.environ = os.environ.copy() - self.temp_dir = self.mkdtemp() - - self.out_dir = os.path.join(self.temp_dir, "out") - self.remote_out_dir = os.path.join(self.temp_dir, "remote") - - os.environ['__cdist_out_dir'] = self.out_dir - os.environ['__cdist_remote_out_dir'] = self.remote_out_dir - - self.context = cdist.context.Context( - target_host=self.target_host, - remote_copy=self.remote_copy, - remote_exec=self.remote_exec, - add_conf_dirs=[add_conf_dir], - exec_path=test.cdist_exec_path, - debug=False) - - self.config = config.Config(self.context) - - def tearDown(self): - os.environ = self.orig_environ - shutil.rmtree(self.temp_dir) - - def test_implicit_dependencies(self): - self.context.initial_manifest = os.path.join(self.context.local.manifest_path, 'implicit_dependencies') - self.config.stage_prepare() - - objects = core.CdistObject.list_objects(self.context.local.object_path, self.context.local.type_path) - dependency_resolver = resolver.DependencyResolver(objects) - expected_dependencies = [ - dependency_resolver.objects['__package_special/b'], - dependency_resolver.objects['__package/b'], - dependency_resolver.objects['__package_special/a'] - ] - resolved_dependencies = dependency_resolver.dependencies['__package_special/a'] - self.assertEqual(resolved_dependencies, expected_dependencies) - - def test_circular_dependency(self): - self.context.initial_manifest = os.path.join(self.context.local.manifest_path, 'circular_dependency') - self.config.stage_prepare() - # raises CircularDependecyError - self.config.stage_run() - - def test_recursive_type(self): - self.context.initial_manifest = os.path.join(self.config.local.manifest_path, 'recursive_type') - self.config.stage_prepare() - # raises CircularDependecyError - self.config.stage_run() diff --git a/cdist/test/resolver/__init__.py b/cdist/test/execution_order/__init__.py similarity index 51% rename from cdist/test/resolver/__init__.py rename to cdist/test/execution_order/__init__.py index baae26de..c792a772 100644 --- a/cdist/test/resolver/__init__.py +++ b/cdist/test/execution_order/__init__.py @@ -86,3 +86,94 @@ class ResolverTestCase(test.CdistTestCase): first_man.requirements = ['__does/not/exist'] with self.assertRaises(cdist.Error): self.dependency_resolver.dependencies +# -*- coding: utf-8 -*- +# +# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +import os +import shutil + +import cdist +from cdist import test +from cdist.exec import local +from cdist import core +from cdist.core import manifest +from cdist import resolver +from cdist import config +import cdist.context + +import os.path as op +my_dir = op.abspath(op.dirname(__file__)) +fixtures = op.join(my_dir, 'fixtures') +add_conf_dir = op.join(fixtures, 'conf') + +class AutorequireTestCase(test.CdistTestCase): + + def setUp(self): + self.orig_environ = os.environ + os.environ = os.environ.copy() + self.temp_dir = self.mkdtemp() + + self.out_dir = os.path.join(self.temp_dir, "out") + self.remote_out_dir = os.path.join(self.temp_dir, "remote") + + os.environ['__cdist_out_dir'] = self.out_dir + os.environ['__cdist_remote_out_dir'] = self.remote_out_dir + + self.context = cdist.context.Context( + target_host=self.target_host, + remote_copy=self.remote_copy, + remote_exec=self.remote_exec, + add_conf_dirs=[add_conf_dir], + exec_path=test.cdist_exec_path, + debug=False) + + self.config = config.Config(self.context) + + def tearDown(self): + os.environ = self.orig_environ + shutil.rmtree(self.temp_dir) + + def test_implicit_dependencies(self): + self.context.initial_manifest = os.path.join(self.context.local.manifest_path, 'implicit_dependencies') + self.config.stage_prepare() + + objects = core.CdistObject.list_objects(self.context.local.object_path, self.context.local.type_path) + dependency_resolver = resolver.DependencyResolver(objects) + expected_dependencies = [ + dependency_resolver.objects['__package_special/b'], + dependency_resolver.objects['__package/b'], + dependency_resolver.objects['__package_special/a'] + ] + resolved_dependencies = dependency_resolver.dependencies['__package_special/a'] + self.assertEqual(resolved_dependencies, expected_dependencies) + + def test_circular_dependency(self): + self.context.initial_manifest = os.path.join(self.context.local.manifest_path, 'circular_dependency') + self.config.stage_prepare() + # raises CircularDependecyError + self.config.stage_run() + + def test_recursive_type(self): + self.context.initial_manifest = os.path.join(self.config.local.manifest_path, 'recursive_type') + self.config.stage_prepare() + # raises CircularDependecyError + self.config.stage_run() diff --git a/cdist/test/autorequire/fixtures/conf/explorer/.keep b/cdist/test/execution_order/fixtures/conf/explorer/.keep similarity index 100% rename from cdist/test/autorequire/fixtures/conf/explorer/.keep rename to cdist/test/execution_order/fixtures/conf/explorer/.keep diff --git a/cdist/test/autorequire/fixtures/conf/manifest/circular_dependency b/cdist/test/execution_order/fixtures/conf/manifest/circular_dependency similarity index 100% rename from cdist/test/autorequire/fixtures/conf/manifest/circular_dependency rename to cdist/test/execution_order/fixtures/conf/manifest/circular_dependency diff --git a/cdist/test/autorequire/fixtures/conf/manifest/implicit_dependencies b/cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies similarity index 100% rename from cdist/test/autorequire/fixtures/conf/manifest/implicit_dependencies rename to cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies diff --git a/cdist/test/autorequire/fixtures/conf/manifest/recursive_type b/cdist/test/execution_order/fixtures/conf/manifest/recursive_type similarity index 100% rename from cdist/test/autorequire/fixtures/conf/manifest/recursive_type rename to cdist/test/execution_order/fixtures/conf/manifest/recursive_type diff --git a/cdist/test/autorequire/fixtures/conf/type/__addifnosuchline/.keep b/cdist/test/execution_order/fixtures/conf/type/__addifnosuchline/.keep similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__addifnosuchline/.keep rename to cdist/test/execution_order/fixtures/conf/type/__addifnosuchline/.keep diff --git a/cdist/test/autorequire/fixtures/conf/type/__directory/.keep b/cdist/test/execution_order/fixtures/conf/type/__directory/.keep similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__directory/.keep rename to cdist/test/execution_order/fixtures/conf/type/__directory/.keep diff --git a/cdist/test/autorequire/fixtures/conf/type/__git/manifest b/cdist/test/execution_order/fixtures/conf/type/__git/manifest similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__git/manifest rename to cdist/test/execution_order/fixtures/conf/type/__git/manifest diff --git a/cdist/test/autorequire/fixtures/conf/type/__nfsroot_client/manifest b/cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__nfsroot_client/manifest rename to cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest diff --git a/cdist/test/autorequire/fixtures/conf/type/__package/manifest b/cdist/test/execution_order/fixtures/conf/type/__package/manifest similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__package/manifest rename to cdist/test/execution_order/fixtures/conf/type/__package/manifest diff --git a/cdist/test/autorequire/fixtures/conf/type/__package_special/.keep b/cdist/test/execution_order/fixtures/conf/type/__package_special/.keep similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__package_special/.keep rename to cdist/test/execution_order/fixtures/conf/type/__package_special/.keep diff --git a/cdist/test/autorequire/fixtures/conf/type/__root_ssh_authorized_key/manifest b/cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__root_ssh_authorized_key/manifest rename to cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest diff --git a/cdist/test/autorequire/fixtures/conf/type/__top/manifest b/cdist/test/execution_order/fixtures/conf/type/__top/manifest similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__top/manifest rename to cdist/test/execution_order/fixtures/conf/type/__top/manifest diff --git a/cdist/test/autorequire/fixtures/conf/type/__user/.keep b/cdist/test/execution_order/fixtures/conf/type/__user/.keep similarity index 100% rename from cdist/test/autorequire/fixtures/conf/type/__user/.keep rename to cdist/test/execution_order/fixtures/conf/type/__user/.keep diff --git a/cdist/test/resolver/fixtures/object/__first/.keep b/cdist/test/execution_order/fixtures/object/__first/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__first/.keep rename to cdist/test/execution_order/fixtures/object/__first/.keep diff --git a/cdist/test/resolver/fixtures/object/__first/child/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__first/child/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__first/child/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__first/child/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__first/dog/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__first/dog/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__first/dog/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__first/dog/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__first/man/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__first/man/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__first/man/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__first/man/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__first/woman/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__first/woman/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__first/woman/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__first/woman/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__second/.keep b/cdist/test/execution_order/fixtures/object/__second/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__second/.keep rename to cdist/test/execution_order/fixtures/object/__second/.keep diff --git a/cdist/test/resolver/fixtures/object/__second/on-the/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__second/on-the/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__second/on-the/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__second/on-the/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__second/under-the/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__second/under-the/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__second/under-the/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__second/under-the/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__third/.keep b/cdist/test/execution_order/fixtures/object/__third/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__third/.keep rename to cdist/test/execution_order/fixtures/object/__third/.keep diff --git a/cdist/test/resolver/fixtures/object/__third/moon/.cdist/.keep b/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/.keep similarity index 100% rename from cdist/test/resolver/fixtures/object/__third/moon/.cdist/.keep rename to cdist/test/execution_order/fixtures/object/__third/moon/.cdist/.keep diff --git a/cdist/test/resolver/fixtures/object/__third/moon/.cdist/parameter/name b/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/name similarity index 100% rename from cdist/test/resolver/fixtures/object/__third/moon/.cdist/parameter/name rename to cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/name diff --git a/cdist/test/resolver/fixtures/object/__third/moon/.cdist/parameter/planet b/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/planet similarity index 100% rename from cdist/test/resolver/fixtures/object/__third/moon/.cdist/parameter/planet rename to cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/planet diff --git a/cdist/test/resolver/fixtures/type/__first/.keep b/cdist/test/execution_order/fixtures/type/__first/.keep similarity index 100% rename from cdist/test/resolver/fixtures/type/__first/.keep rename to cdist/test/execution_order/fixtures/type/__first/.keep diff --git a/cdist/test/resolver/fixtures/type/__second/.keep b/cdist/test/execution_order/fixtures/type/__second/.keep similarity index 100% rename from cdist/test/resolver/fixtures/type/__second/.keep rename to cdist/test/execution_order/fixtures/type/__second/.keep diff --git a/cdist/test/resolver/fixtures/type/__third/.keep b/cdist/test/execution_order/fixtures/type/__third/.keep similarity index 100% rename from cdist/test/resolver/fixtures/type/__third/.keep rename to cdist/test/execution_order/fixtures/type/__third/.keep