fix unit tests for config_install
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
4ec1afc47f
commit
e1d8645415
2 changed files with 11 additions and 17 deletions
|
@ -32,18 +32,16 @@ from cdist import core
|
||||||
class ConfigInstall(object):
|
class ConfigInstall(object):
|
||||||
"""Cdist main class to hold arbitrary data"""
|
"""Cdist main class to hold arbitrary data"""
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context, dry_run=False):
|
||||||
|
|
||||||
self.context = context
|
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.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.manifest = core.Manifest(self.context.target_host, self.context.local)
|
||||||
self.code = core.Code(self.context.target_host, self.context.local, self.context.remote)
|
self.code = core.Code(self.context.target_host, self.context.local, self.context.remote)
|
||||||
|
|
||||||
# Add switch to disable code execution
|
|
||||||
self.dry_run = False
|
|
||||||
|
|
||||||
def _init_files_dirs(self):
|
def _init_files_dirs(self):
|
||||||
"""Prepare files and directories for the run"""
|
"""Prepare files and directories for the run"""
|
||||||
self.context.local.create_files_dirs()
|
self.context.local.create_files_dirs()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -86,15 +86,15 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
# First run:
|
# First run:
|
||||||
# solves first and maybe second (depending on the order in the set)
|
# 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.assertTrue(third.state == third.STATE_DONE)
|
||||||
|
|
||||||
self.config.stage_run_iterate()
|
self.config.iterate_once()
|
||||||
self.assertTrue(second.state == second.STATE_DONE)
|
self.assertTrue(second.state == second.STATE_DONE)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.config.stage_run_iterate()
|
self.config.iterate_once()
|
||||||
except cdist.Error:
|
except cdist.Error:
|
||||||
# Allow failing, because the third run may or may not be unecessary already,
|
# Allow failing, because the third run may or may not be unecessary already,
|
||||||
# depending on the order of the objects
|
# depending on the order of the objects
|
||||||
|
@ -111,9 +111,5 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
|
||||||
first.requirements = [second.name]
|
first.requirements = [second.name]
|
||||||
second.requirements = [first.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):
|
with self.assertRaises(cdist.Error):
|
||||||
self.config.stage_run_iterate()
|
self.config.iterate_until_finished()
|
||||||
|
|
Loading…
Reference in a new issue