mere tests of autorequire and resolver into execution_order

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
remotes/origin/ssh_callback
Nico Schottelius 12 years ago
parent 782d84870d
commit ae8040536f
  1. 91
      cdist/test/autorequire/__init__.py
  2. 91
      cdist/test/execution_order/__init__.py
  3. 0
      cdist/test/execution_order/fixtures/conf/explorer/.keep
  4. 0
      cdist/test/execution_order/fixtures/conf/manifest/circular_dependency
  5. 0
      cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies
  6. 0
      cdist/test/execution_order/fixtures/conf/manifest/recursive_type
  7. 0
      cdist/test/execution_order/fixtures/conf/type/__addifnosuchline/.keep
  8. 0
      cdist/test/execution_order/fixtures/conf/type/__directory/.keep
  9. 0
      cdist/test/execution_order/fixtures/conf/type/__git/manifest
  10. 0
      cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest
  11. 0
      cdist/test/execution_order/fixtures/conf/type/__package/manifest
  12. 0
      cdist/test/execution_order/fixtures/conf/type/__package_special/.keep
  13. 0
      cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest
  14. 0
      cdist/test/execution_order/fixtures/conf/type/__top/manifest
  15. 0
      cdist/test/execution_order/fixtures/conf/type/__user/.keep
  16. 0
      cdist/test/execution_order/fixtures/object/__first/.keep
  17. 0
      cdist/test/execution_order/fixtures/object/__first/child/.cdist/.keep
  18. 0
      cdist/test/execution_order/fixtures/object/__first/dog/.cdist/.keep
  19. 0
      cdist/test/execution_order/fixtures/object/__first/man/.cdist/.keep
  20. 0
      cdist/test/execution_order/fixtures/object/__first/woman/.cdist/.keep
  21. 0
      cdist/test/execution_order/fixtures/object/__second/.keep
  22. 0
      cdist/test/execution_order/fixtures/object/__second/on-the/.cdist/.keep
  23. 0
      cdist/test/execution_order/fixtures/object/__second/under-the/.cdist/.keep
  24. 0
      cdist/test/execution_order/fixtures/object/__third/.keep
  25. 0
      cdist/test/execution_order/fixtures/object/__third/moon/.cdist/.keep
  26. 0
      cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/name
  27. 0
      cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/planet
  28. 0
      cdist/test/execution_order/fixtures/type/__first/.keep
  29. 0
      cdist/test/execution_order/fixtures/type/__second/.keep
  30. 0
      cdist/test/execution_order/fixtures/type/__third/.keep

@ -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 <http://www.gnu.org/licenses/>.
#
#
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()

@ -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 <http://www.gnu.org/licenses/>.
#
#
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()
Loading…
Cancel
Save