fix unit tests for config_install

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-06-21 21:48:15 +02:00
parent 4ec1afc47f
commit e1d8645415
2 changed files with 11 additions and 17 deletions

View File

@ -32,17 +32,15 @@ from cdist import core
class ConfigInstall(object):
"""Cdist main class to hold arbitrary data"""
def __init__(self, context):
def __init__(self, context, dry_run=False):
self.context = context
self.log = logging.getLogger(self.context.target_host)
self.log = logging.getLogger(self.context.target_host)
self.dry_run = dry_run
self.explorer = core.Explorer(self.context.target_host, self.context.local, self.context.remote)
self.manifest = core.Manifest(self.context.target_host, self.context.local)
self.code = core.Code(self.context.target_host, self.context.local, self.context.remote)
# Add switch to disable code execution
self.dry_run = False
self.code = core.Code(self.context.target_host, self.context.local, self.context.remote)
def _init_files_dirs(self):
"""Prepare files and directories for the run"""

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -59,8 +59,8 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
exec_path=test.cdist_exec_path,
debug=True)
self.context.local.object_path = object_base_path
self.context.local.type_path = type_base_path
self.context.local.object_path = object_base_path
self.context.local.type_path = type_base_path
self.config = cdist.config.Config(self.context)
@ -86,15 +86,15 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
# First run:
# solves first and maybe second (depending on the order in the set)
self.config.stage_run_iterate()
self.config.iterate_once()
self.assertTrue(third.state == third.STATE_DONE)
self.config.stage_run_iterate()
self.config.iterate_once()
self.assertTrue(second.state == second.STATE_DONE)
try:
self.config.stage_run_iterate()
self.config.iterate_once()
except cdist.Error:
# Allow failing, because the third run may or may not be unecessary already,
# depending on the order of the objects
@ -111,9 +111,5 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
first.requirements = [second.name]
second.requirements = [first.name]
# First round solves __third/moon
self.config.stage_run_iterate()
# Second round detects it cannot solve the rest
with self.assertRaises(cdist.Error):
self.config.stage_run_iterate()
self.config.iterate_until_finished()