From 25bdcb1602070973c958cc0f195510304b3055d0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Jun 2013 22:39:20 +0200 Subject: [PATCH] cleanup tests and ... - 100% green Signed-off-by: Nico Schottelius --- cdist/__init__.py | 4 + cdist/config_install.py | 2 +- cdist/core/cdist_object.py | 7 -- .../test/{object => cdist_object}/__init__.py | 51 -------- .../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 .../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 cdist/test/{type => cdist_type}/__init__.py | 0 .../fixtures/__install/install | 0 .../fixtures/__name_path}/.keep | 0 .../fixtures/__not_install}/.keep | 0 .../fixtures/__not_singleton}/.keep | 0 .../fixtures/__singleton/singleton | 0 .../parameter/boolean | 0 .../__with_explorers/explorer/whatever | 0 .../parameter/optional | 0 .../parameter/required | 0 .../__without_boolean_parameters}/.keep | 0 .../fixtures/__without_explorers}/.keep | 0 .../__without_optional_parameters}/.keep | 0 .../__without_required_parameters}/.keep | 0 .../fixtures/list_types/__first}/.keep | 0 .../fixtures/list_types/__second}/.keep | 0 .../fixtures/list_types/__third}/.keep | 0 cdist/test/config_install/__init__.py | 34 ++++- .../fixtures/type/__singleton_test/singleton} | 0 cdist/test/execution_order/__init__.py | 116 ------------------ .../conf/manifest/circular_dependency | 2 - .../conf/manifest/implicit_dependencies | 3 - .../fixtures/conf/manifest/recursive_type | 2 - .../fixtures/conf/type/__git/manifest | 1 - .../conf/type/__nfsroot_client/manifest | 3 - .../fixtures/conf/type/__package/manifest | 1 - .../type/__root_ssh_authorized_key/manifest | 4 - .../fixtures/conf/type/__top/manifest | 2 - .../object/__second/on-the/.cdist/.keep | 0 .../object/__second/under-the/.cdist/.keep | 0 .../test/object/fixtures/object/__third/.keep | 0 .../fixtures/object/__third/moon/.cdist/.keep | 0 .../object/__third/moon/.cdist/parameter/name | 1 - .../__third/moon/.cdist/parameter/planet | 1 - cdist/test/object/fixtures/type/__first/.keep | 0 .../test/object/fixtures/type/__second/.keep | 0 cdist/test/object/fixtures/type/__third/.keep | 0 cdist/test/type/fixtures/__name_path/.keep | 0 cdist/test/type/fixtures/__not_install/.keep | 0 .../test/type/fixtures/__not_singleton/.keep | 0 .../__without_boolean_parameters/.keep | 0 .../type/fixtures/__without_explorers/.keep | 0 .../__without_optional_parameters/.keep | 0 .../__without_required_parameters/.keep | 0 .../type/fixtures/list_types/__first/.keep | 0 .../type/fixtures/list_types/__second/.keep | 0 .../type/fixtures/list_types/__third/.keep | 0 66 files changed, 36 insertions(+), 198 deletions(-) rename cdist/test/{object => cdist_object}/__init__.py (81%) rename cdist/test/{execution_order/fixtures/conf/explorer => cdist_object/fixtures/object/__first}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__addifnosuchline => cdist_object/fixtures/object/__first/child/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__directory => cdist_object/fixtures/object/__first/dog/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__first => cdist_object/fixtures/object/__first/man/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__package_special => cdist_object/fixtures/object/__first/woman/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type => cdist_object/fixtures/object}/__second/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__third => cdist_object/fixtures/object/__second/on-the/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/conf/type/__user => cdist_object/fixtures/object/__second/under-the/.cdist}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__first => cdist_object/fixtures/object/__third}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__first/child => cdist_object/fixtures/object/__third/moon}/.cdist/.keep (100%) rename cdist/test/{execution_order => cdist_object}/fixtures/object/__third/moon/.cdist/parameter/name (100%) rename cdist/test/{execution_order => cdist_object}/fixtures/object/__third/moon/.cdist/parameter/planet (100%) rename cdist/test/{execution_order/fixtures/object/__first/dog/.cdist => cdist_object/fixtures/type/__first}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__first/man/.cdist => cdist_object/fixtures/type/__second}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__first/woman/.cdist => cdist_object/fixtures/type/__third}/.keep (100%) rename cdist/test/{type => cdist_type}/__init__.py (100%) rename cdist/test/{type => cdist_type}/fixtures/__install/install (100%) rename cdist/test/{execution_order/fixtures/object/__second => cdist_type/fixtures/__name_path}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__second/on-the/.cdist => cdist_type/fixtures/__not_install}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__second/under-the/.cdist => cdist_type/fixtures/__not_singleton}/.keep (100%) rename cdist/test/{type => cdist_type}/fixtures/__singleton/singleton (100%) rename cdist/test/{type => cdist_type}/fixtures/__with_boolean_parameters/parameter/boolean (100%) rename cdist/test/{type => cdist_type}/fixtures/__with_explorers/explorer/whatever (100%) rename cdist/test/{type => cdist_type}/fixtures/__with_optional_parameters/parameter/optional (100%) rename cdist/test/{type => cdist_type}/fixtures/__with_required_parameters/parameter/required (100%) rename cdist/test/{execution_order/fixtures/object/__third => cdist_type/fixtures/__without_boolean_parameters}/.keep (100%) rename cdist/test/{execution_order/fixtures/object/__third/moon/.cdist => cdist_type/fixtures/__without_explorers}/.keep (100%) rename cdist/test/{object/fixtures/object/__first => cdist_type/fixtures/__without_optional_parameters}/.keep (100%) rename cdist/test/{object/fixtures/object/__first/child/.cdist => cdist_type/fixtures/__without_required_parameters}/.keep (100%) rename cdist/test/{object/fixtures/object/__first/dog/.cdist => cdist_type/fixtures/list_types/__first}/.keep (100%) rename cdist/test/{object/fixtures/object/__first/man/.cdist => cdist_type/fixtures/list_types/__second}/.keep (100%) rename cdist/test/{object/fixtures/object/__first/woman/.cdist => cdist_type/fixtures/list_types/__third}/.keep (100%) rename cdist/test/{object/fixtures/object/__second/.keep => config_install/fixtures/type/__singleton_test/singleton} (100%) delete mode 100644 cdist/test/execution_order/__init__.py delete mode 100755 cdist/test/execution_order/fixtures/conf/manifest/circular_dependency delete mode 100755 cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies delete mode 100755 cdist/test/execution_order/fixtures/conf/manifest/recursive_type delete mode 100644 cdist/test/execution_order/fixtures/conf/type/__git/manifest delete mode 100755 cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest delete mode 100755 cdist/test/execution_order/fixtures/conf/type/__package/manifest delete mode 100755 cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest delete mode 100755 cdist/test/execution_order/fixtures/conf/type/__top/manifest delete mode 100644 cdist/test/object/fixtures/object/__second/on-the/.cdist/.keep delete mode 100644 cdist/test/object/fixtures/object/__second/under-the/.cdist/.keep delete mode 100644 cdist/test/object/fixtures/object/__third/.keep delete mode 100644 cdist/test/object/fixtures/object/__third/moon/.cdist/.keep delete mode 100644 cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/name delete mode 100644 cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/planet delete mode 100644 cdist/test/object/fixtures/type/__first/.keep delete mode 100644 cdist/test/object/fixtures/type/__second/.keep delete mode 100644 cdist/test/object/fixtures/type/__third/.keep delete mode 100644 cdist/test/type/fixtures/__name_path/.keep delete mode 100644 cdist/test/type/fixtures/__not_install/.keep delete mode 100644 cdist/test/type/fixtures/__not_singleton/.keep delete mode 100644 cdist/test/type/fixtures/__without_boolean_parameters/.keep delete mode 100644 cdist/test/type/fixtures/__without_explorers/.keep delete mode 100644 cdist/test/type/fixtures/__without_optional_parameters/.keep delete mode 100644 cdist/test/type/fixtures/__without_required_parameters/.keep delete mode 100644 cdist/test/type/fixtures/list_types/__first/.keep delete mode 100644 cdist/test/type/fixtures/list_types/__second/.keep delete mode 100644 cdist/test/type/fixtures/list_types/__third/.keep diff --git a/cdist/__init__.py b/cdist/__init__.py index 02d708b1..bd45e740 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -47,6 +47,10 @@ class Error(Exception): """Base exception class for this project""" pass +class UnresolvableRequirementsError(cdist.Error): + """Resolving requirements failed""" + pass + class CdistObjectError(Error): """Something went wrong with an object""" diff --git a/cdist/config_install.py b/cdist/config_install.py index db7e3792..c8c18ce7 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -131,7 +131,7 @@ class ConfigInstall(object): autorequire = ", ".join(autorequire_names) info_string.append("%s requires: %s autorequires: %s" % (cdist_object.name, requirements, autorequire)) - raise cdist.Error("The requirements of the following objects could not be resolved: %s" % + raise cdist.UnresolvableRequirementsError("The requirements of the following objects could not be resolved: %s" % ("; ".join(info_string))) def object_prepare(self, cdist_object): diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 4df85b9f..04fb404c 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -235,10 +235,3 @@ class CdistObject(object): object_list.append(cdist_object) return object_list - -class RequirementNotFoundError(cdist.Error): - def __init__(self, requirement): - self.requirement = requirement - - def __str__(self): - return 'Requirement could not be found: %s' % self.requirement diff --git a/cdist/test/object/__init__.py b/cdist/test/cdist_object/__init__.py similarity index 81% rename from cdist/test/object/__init__.py rename to cdist/test/cdist_object/__init__.py index c4f46cd1..70506da4 100644 --- a/cdist/test/object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -212,54 +212,3 @@ class ObjectTestCase(test.CdistTestCase): self.assertTrue(isinstance(other_object, core.CdistObject)) self.assertEqual(other_object.cdist_type.name, '__first') self.assertEqual(other_object.object_id, 'man') - - - -class ObjectResolveRequirementsTestCase(test.CdistTestCase): - - def setUp(self): - self.objects = list(core.CdistObject.list_objects(object_base_path, type_base_path)) - self.object_index = dict((o.name, o) for o in self.objects) - self.object_names = [o.name for o in self.objects] - - print(self.objects) - - self.cdist_type = core.CdistType(type_base_path, '__third') - self.cdist_object = core.CdistObject(self.cdist_type, object_base_path, 'moon') - - def tearDown(self): - for o in self.objects: - o.requirements = [] - - def test_find_requirements_by_name_string(self): - """Check that resolving requirements by name works (require all objects)""" - requirements = self.object_names - - self.cdist_object.requirements = requirements - - found_requirements = sorted(self.cdist_object.find_requirements_by_name(self.cdist_object.requirements)) - expected_requirements = sorted(self.objects) - - self.assertEqual(found_requirements, expected_requirements) - - def test_find_requirements_by_name_pattern(self): - """Test whether pattern matching on requirements works""" - - # Matches all objects in the end - requirements = ['__first/*', '__second/*-the', '__third/moon'] - - self.cdist_object.requirements = requirements - - expected_requirements = sorted(self.objects) - found_requirements = sorted(self.cdist_object.find_requirements_by_name(self.cdist_object.requirements)) - - self.assertEqual(expected_requirements, found_requirements) - - def test_requirement_not_found(self): - """Ensure an exception is thrown for missing depedencies""" - cdist_object = self.object_index['__first/man'] - cdist_object.requirements = ['__does/not/exist'] - - with self.assertRaises(core.cdist_object.RequirementNotFoundError): - # Use list, as generator does not (yet) raise the error - list(cdist_object.find_requirements_by_name(cdist_object.requirements)) diff --git a/cdist/test/execution_order/fixtures/conf/explorer/.keep b/cdist/test/cdist_object/fixtures/object/__first/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/explorer/.keep rename to cdist/test/cdist_object/fixtures/object/__first/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__addifnosuchline/.keep b/cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__addifnosuchline/.keep rename to cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__directory/.keep b/cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__directory/.keep rename to cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__first/.keep b/cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__first/.keep rename to cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__package_special/.keep b/cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__package_special/.keep rename to cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__second/.keep b/cdist/test/cdist_object/fixtures/object/__second/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__second/.keep rename to cdist/test/cdist_object/fixtures/object/__second/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__third/.keep b/cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__third/.keep rename to cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/conf/type/__user/.keep b/cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/conf/type/__user/.keep rename to cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/object/__first/.keep b/cdist/test/cdist_object/fixtures/object/__third/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__first/.keep rename to cdist/test/cdist_object/fixtures/object/__third/.keep diff --git a/cdist/test/execution_order/fixtures/object/__first/child/.cdist/.keep b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__first/child/.cdist/.keep rename to cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep diff --git a/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/name b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/name similarity index 100% rename from cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/name rename to cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/name diff --git a/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/planet b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/planet similarity index 100% rename from cdist/test/execution_order/fixtures/object/__third/moon/.cdist/parameter/planet rename to cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/planet diff --git a/cdist/test/execution_order/fixtures/object/__first/dog/.cdist/.keep b/cdist/test/cdist_object/fixtures/type/__first/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__first/dog/.cdist/.keep rename to cdist/test/cdist_object/fixtures/type/__first/.keep diff --git a/cdist/test/execution_order/fixtures/object/__first/man/.cdist/.keep b/cdist/test/cdist_object/fixtures/type/__second/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__first/man/.cdist/.keep rename to cdist/test/cdist_object/fixtures/type/__second/.keep diff --git a/cdist/test/execution_order/fixtures/object/__first/woman/.cdist/.keep b/cdist/test/cdist_object/fixtures/type/__third/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__first/woman/.cdist/.keep rename to cdist/test/cdist_object/fixtures/type/__third/.keep diff --git a/cdist/test/type/__init__.py b/cdist/test/cdist_type/__init__.py similarity index 100% rename from cdist/test/type/__init__.py rename to cdist/test/cdist_type/__init__.py diff --git a/cdist/test/type/fixtures/__install/install b/cdist/test/cdist_type/fixtures/__install/install similarity index 100% rename from cdist/test/type/fixtures/__install/install rename to cdist/test/cdist_type/fixtures/__install/install diff --git a/cdist/test/execution_order/fixtures/object/__second/.keep b/cdist/test/cdist_type/fixtures/__name_path/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__second/.keep rename to cdist/test/cdist_type/fixtures/__name_path/.keep diff --git a/cdist/test/execution_order/fixtures/object/__second/on-the/.cdist/.keep b/cdist/test/cdist_type/fixtures/__not_install/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__second/on-the/.cdist/.keep rename to cdist/test/cdist_type/fixtures/__not_install/.keep diff --git a/cdist/test/execution_order/fixtures/object/__second/under-the/.cdist/.keep b/cdist/test/cdist_type/fixtures/__not_singleton/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__second/under-the/.cdist/.keep rename to cdist/test/cdist_type/fixtures/__not_singleton/.keep diff --git a/cdist/test/type/fixtures/__singleton/singleton b/cdist/test/cdist_type/fixtures/__singleton/singleton similarity index 100% rename from cdist/test/type/fixtures/__singleton/singleton rename to cdist/test/cdist_type/fixtures/__singleton/singleton diff --git a/cdist/test/type/fixtures/__with_boolean_parameters/parameter/boolean b/cdist/test/cdist_type/fixtures/__with_boolean_parameters/parameter/boolean similarity index 100% rename from cdist/test/type/fixtures/__with_boolean_parameters/parameter/boolean rename to cdist/test/cdist_type/fixtures/__with_boolean_parameters/parameter/boolean diff --git a/cdist/test/type/fixtures/__with_explorers/explorer/whatever b/cdist/test/cdist_type/fixtures/__with_explorers/explorer/whatever similarity index 100% rename from cdist/test/type/fixtures/__with_explorers/explorer/whatever rename to cdist/test/cdist_type/fixtures/__with_explorers/explorer/whatever diff --git a/cdist/test/type/fixtures/__with_optional_parameters/parameter/optional b/cdist/test/cdist_type/fixtures/__with_optional_parameters/parameter/optional similarity index 100% rename from cdist/test/type/fixtures/__with_optional_parameters/parameter/optional rename to cdist/test/cdist_type/fixtures/__with_optional_parameters/parameter/optional diff --git a/cdist/test/type/fixtures/__with_required_parameters/parameter/required b/cdist/test/cdist_type/fixtures/__with_required_parameters/parameter/required similarity index 100% rename from cdist/test/type/fixtures/__with_required_parameters/parameter/required rename to cdist/test/cdist_type/fixtures/__with_required_parameters/parameter/required diff --git a/cdist/test/execution_order/fixtures/object/__third/.keep b/cdist/test/cdist_type/fixtures/__without_boolean_parameters/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__third/.keep rename to cdist/test/cdist_type/fixtures/__without_boolean_parameters/.keep diff --git a/cdist/test/execution_order/fixtures/object/__third/moon/.cdist/.keep b/cdist/test/cdist_type/fixtures/__without_explorers/.keep similarity index 100% rename from cdist/test/execution_order/fixtures/object/__third/moon/.cdist/.keep rename to cdist/test/cdist_type/fixtures/__without_explorers/.keep diff --git a/cdist/test/object/fixtures/object/__first/.keep b/cdist/test/cdist_type/fixtures/__without_optional_parameters/.keep similarity index 100% rename from cdist/test/object/fixtures/object/__first/.keep rename to cdist/test/cdist_type/fixtures/__without_optional_parameters/.keep diff --git a/cdist/test/object/fixtures/object/__first/child/.cdist/.keep b/cdist/test/cdist_type/fixtures/__without_required_parameters/.keep similarity index 100% rename from cdist/test/object/fixtures/object/__first/child/.cdist/.keep rename to cdist/test/cdist_type/fixtures/__without_required_parameters/.keep diff --git a/cdist/test/object/fixtures/object/__first/dog/.cdist/.keep b/cdist/test/cdist_type/fixtures/list_types/__first/.keep similarity index 100% rename from cdist/test/object/fixtures/object/__first/dog/.cdist/.keep rename to cdist/test/cdist_type/fixtures/list_types/__first/.keep diff --git a/cdist/test/object/fixtures/object/__first/man/.cdist/.keep b/cdist/test/cdist_type/fixtures/list_types/__second/.keep similarity index 100% rename from cdist/test/object/fixtures/object/__first/man/.cdist/.keep rename to cdist/test/cdist_type/fixtures/list_types/__second/.keep diff --git a/cdist/test/object/fixtures/object/__first/woman/.cdist/.keep b/cdist/test/cdist_type/fixtures/list_types/__third/.keep similarity index 100% rename from cdist/test/object/fixtures/object/__first/woman/.cdist/.keep rename to cdist/test/cdist_type/fixtures/list_types/__third/.keep diff --git a/cdist/test/config_install/__init__.py b/cdist/test/config_install/__init__.py index fab31cc9..b8daf4f8 100644 --- a/cdist/test/config_install/__init__.py +++ b/cdist/test/config_install/__init__.py @@ -29,6 +29,8 @@ from cdist import core import cdist import cdist.context import cdist.config +import cdist.core.cdist_type +import cdist.core.cdist_object import os.path as op my_dir = op.abspath(op.dirname(__file__)) @@ -111,11 +113,37 @@ class ConfigInstallRunTestCase(test.CdistTestCase): first.requirements = [second.name] second.requirements = [first.name] - with self.assertRaises(cdist.Error): + with self.assertRaises(cdist.UnresolvableRequirementsError): self.config.iterate_until_finished() def test_missing_requirements(self): + """Throw an error if requiring something non-existing""" first = self.object_index['__first/man'] - first.requirements = ['__does/not/exist'] - with self.assertRaises(cdist.Error): + first.requirements = ['__first/not/exist'] + with self.assertRaises(cdist.UnresolvableRequirementsError): self.config.iterate_until_finished() + + def test_requirement_broken_type(self): + """Unknown type should be detected in the resolving process""" + first = self.object_index['__first/man'] + first.requirements = ['__nosuchtype/not/exist'] + with self.assertRaises(cdist.core.cdist_type.NoSuchTypeError): + self.config.iterate_until_finished() + + def test_requirement_singleton_where_no_singleton(self): + """Missing object id should be detected in the resolving process""" + first = self.object_index['__first/man'] + first.requirements = ['__first'] + with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError): + self.config.iterate_until_finished() + +# Currently the resolving code will simply detect that this object does +# not exist. It should probably check if the type is a singleton as well +# - but maybe only in the emulator - to be discussed. +# +# def test_requirement_no_singleton_where_singleton(self): +# """Missing object id should be detected in the resolving process""" +# first = self.object_index['__first/man'] +# first.requirements = ['__singleton_test/foo'] +# with self.assertRaises(cdist.core.?????): +# self.config.iterate_until_finished() diff --git a/cdist/test/object/fixtures/object/__second/.keep b/cdist/test/config_install/fixtures/type/__singleton_test/singleton similarity index 100% rename from cdist/test/object/fixtures/object/__second/.keep rename to cdist/test/config_install/fixtures/type/__singleton_test/singleton diff --git a/cdist/test/execution_order/__init__.py b/cdist/test/execution_order/__init__.py deleted file mode 100644 index 604000a2..00000000 --- a/cdist/test/execution_order/__init__.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2013 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 import core -from cdist import config -from cdist.exec import local -from cdist.core import manifest -import cdist.context - -import os.path as op -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') - -object_base_path = op.join(fixtures, 'object') -add_conf_dir = op.join(fixtures, 'conf') -type_base_path = op.join(add_conf_dir, 'type') - -class MockContext(object): - """A context object that has the required attributes""" - def __init__(self, target_host): - self.target_host = target_host - self.local = False - -class MockLocal(object): - def __init__(self, temp_dir, type_path): - self.temp_dir = temp_dir - self.object_path = op.join(self.temp_dir, "object") - self.type_path = type_path - -class ExecutionOrderTestCase(test.CdistTestCase): - def setUp(self): - # self.orig_environ = os.environ - # os.environ = os.environ.copy() - # os.environ['__cdist_out_dir'] = self.out_dir - # os.environ['__cdist_remote_out_dir'] = self.remote_out_dir - # self.out_dir = os.path.join(self.temp_dir, "out") - # self.remote_out_dir = os.path.join(self.temp_dir, "remote") - - self.temp_dir = self.mkdtemp() - - self.context = MockContext(self.target_host) - self.context.local = MockLocal(self.temp_dir, type_base_path) - self.config = config.Config(self.context) - - self._init_objects() - - def _init_objects(self): - """copy base objects to context directory""" - shutil.copytree(object_base_path, self.context.local.object_path) - self.objects = list(core.CdistObject.list_objects(self.context.local.object_path, self.context.local.type_path)) - self.object_index = dict((o.name, o) for o in self.objects) - - for cdist_object in self.objects: - cdist_object.state = core.CdistObject.STATE_UNDEF - - def tearDown(self): - # os.environ = self.orig_environ - shutil.rmtree(self.temp_dir) - - def test_objects_changed(self): - pass - # self.assert_True(self.config.iterate_once()) - -class NotTheExecutionOrderTestCase(test.CdistTestCase): - 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) - self.assertTrue(False) - - 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() - self.assertTrue(False) - - 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() - self.assertTrue(False) diff --git a/cdist/test/execution_order/fixtures/conf/manifest/circular_dependency b/cdist/test/execution_order/fixtures/conf/manifest/circular_dependency deleted file mode 100755 index 6ea308d1..00000000 --- a/cdist/test/execution_order/fixtures/conf/manifest/circular_dependency +++ /dev/null @@ -1,2 +0,0 @@ -# this has triggered CircularReferenceError -__nfsroot_client test diff --git a/cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies b/cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies deleted file mode 100755 index 7d68aed2..00000000 --- a/cdist/test/execution_order/fixtures/conf/manifest/implicit_dependencies +++ /dev/null @@ -1,3 +0,0 @@ -# this creates implicit dependencies through autorequire. -# this failed because autorequired dependencies where not aware of their anchestors dependencies -__top test diff --git a/cdist/test/execution_order/fixtures/conf/manifest/recursive_type b/cdist/test/execution_order/fixtures/conf/manifest/recursive_type deleted file mode 100755 index c32b7710..00000000 --- a/cdist/test/execution_order/fixtures/conf/manifest/recursive_type +++ /dev/null @@ -1,2 +0,0 @@ -__git foo -require="__git/foo" __git bar diff --git a/cdist/test/execution_order/fixtures/conf/type/__git/manifest b/cdist/test/execution_order/fixtures/conf/type/__git/manifest deleted file mode 100644 index 616ecca9..00000000 --- a/cdist/test/execution_order/fixtures/conf/type/__git/manifest +++ /dev/null @@ -1 +0,0 @@ -__package git diff --git a/cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest b/cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest deleted file mode 100755 index f6cb7833..00000000 --- a/cdist/test/execution_order/fixtures/conf/type/__nfsroot_client/manifest +++ /dev/null @@ -1,3 +0,0 @@ -__user root -__root_ssh_authorized_key john -__root_ssh_authorized_key frank diff --git a/cdist/test/execution_order/fixtures/conf/type/__package/manifest b/cdist/test/execution_order/fixtures/conf/type/__package/manifest deleted file mode 100755 index 6f70e627..00000000 --- a/cdist/test/execution_order/fixtures/conf/type/__package/manifest +++ /dev/null @@ -1 +0,0 @@ -__package_special "$__object_id" diff --git a/cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest b/cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest deleted file mode 100755 index 6224629f..00000000 --- a/cdist/test/execution_order/fixtures/conf/type/__root_ssh_authorized_key/manifest +++ /dev/null @@ -1,4 +0,0 @@ -user="$__object_id" -__directory /root/.ssh -require="__directory/root/.ssh" \ - __addifnosuchline "ssh-root-$user" diff --git a/cdist/test/execution_order/fixtures/conf/type/__top/manifest b/cdist/test/execution_order/fixtures/conf/type/__top/manifest deleted file mode 100755 index d6968c25..00000000 --- a/cdist/test/execution_order/fixtures/conf/type/__top/manifest +++ /dev/null @@ -1,2 +0,0 @@ -__package b -require="__package/b" __package a diff --git a/cdist/test/object/fixtures/object/__second/on-the/.cdist/.keep b/cdist/test/object/fixtures/object/__second/on-the/.cdist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/object/__second/under-the/.cdist/.keep b/cdist/test/object/fixtures/object/__second/under-the/.cdist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/object/__third/.keep b/cdist/test/object/fixtures/object/__third/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/object/__third/moon/.cdist/.keep b/cdist/test/object/fixtures/object/__third/moon/.cdist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/name b/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/name deleted file mode 100644 index 4129a761..00000000 --- a/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/name +++ /dev/null @@ -1 +0,0 @@ -Prometheus diff --git a/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/planet b/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/planet deleted file mode 100644 index 8e6ee422..00000000 --- a/cdist/test/object/fixtures/object/__third/moon/.cdist/parameter/planet +++ /dev/null @@ -1 +0,0 @@ -Saturn diff --git a/cdist/test/object/fixtures/type/__first/.keep b/cdist/test/object/fixtures/type/__first/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/type/__second/.keep b/cdist/test/object/fixtures/type/__second/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/object/fixtures/type/__third/.keep b/cdist/test/object/fixtures/type/__third/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__name_path/.keep b/cdist/test/type/fixtures/__name_path/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__not_install/.keep b/cdist/test/type/fixtures/__not_install/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__not_singleton/.keep b/cdist/test/type/fixtures/__not_singleton/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__without_boolean_parameters/.keep b/cdist/test/type/fixtures/__without_boolean_parameters/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__without_explorers/.keep b/cdist/test/type/fixtures/__without_explorers/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__without_optional_parameters/.keep b/cdist/test/type/fixtures/__without_optional_parameters/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/__without_required_parameters/.keep b/cdist/test/type/fixtures/__without_required_parameters/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/list_types/__first/.keep b/cdist/test/type/fixtures/list_types/__first/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/list_types/__second/.keep b/cdist/test/type/fixtures/list_types/__second/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/type/fixtures/list_types/__third/.keep b/cdist/test/type/fixtures/list_types/__third/.keep deleted file mode 100644 index e69de29b..00000000