Merge branch 'enhance_cache'

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>

Conflicts:
	cdist/test/code/__init__.py
	cdist/test/config_install/__init__.py
	cdist/test/explorer/__init__.py
This commit is contained in:
Nico Schottelius 2013-08-28 15:43:03 +02:00
commit e6feee14fb
12 changed files with 87 additions and 67 deletions

View file

@ -39,18 +39,16 @@ conf_dir = op.join(fixtures, 'conf')
class CodeTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
self.out_path = self.mkdtemp()
self.local_dir = self.mkdtemp()
self.local = local.Local(
target_host=self.target_host,
out_path = self.out_path,
base_path = self.local_dir,
exec_path = cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
self.remote_base_path = self.mkdtemp()
self.remote_dir = self.mkdtemp()
remote_exec = self.remote_exec
remote_copy = self.remote_copy
self.remote = remote.Remote(
@ -58,7 +56,7 @@ class CodeTestCase(test.CdistTestCase):
remote_exec=remote_exec,
remote_copy=remote_copy)
self.remote.base_path = self.remote_base_path
self.remote.create_files_dirs()
tself.remote.create_files_dirs()
self.code = code.Code(self.target_host, self.local, self.remote)
@ -67,8 +65,8 @@ class CodeTestCase(test.CdistTestCase):
self.cdist_object.create()
def tearDown(self):
shutil.rmtree(self.out_path)
shutil.rmtree(self.remote_base_path)
shutil.rmtree(self.local_dir)
shutil.rmtree(self.remote_dir)
def test_run_gencode_local_environment(self):
output_string = self.code.run_gencode_local(self.cdist_object)
@ -79,7 +77,7 @@ class CodeTestCase(test.CdistTestCase):
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id)
@ -94,7 +92,7 @@ class CodeTestCase(test.CdistTestCase):
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id)

View file

@ -47,19 +47,19 @@ class ConfigInstallRunTestCase(test.CdistTestCase):
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.local = cdist.exec.local(
self.local_dir = os.path.join(self.temp_dir, "local")
os.mkdir(self.local_dir)
self.local = cdist.exec.local.Local(
target_host=self.target_host,
exec_path=test.cdist_exec_path)
self.remote = cdist.exec.remote(
base_path=self.local_dir)
self.remote_dir = os.path.join(self.temp_dir, "remote")
os.mkdir(self.remote_dir)
self.remote = cdist.exec.remote.Remote(
target_host=self.target_host,
remote_copy=self.remote_copy,
remote_exec=self.remote_exec)
remote_exec=self.remote_exec,
base_path=self.remote_dir)
self.local.object_path = object_base_path
self.local.type_path = type_base_path

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.
#
@ -45,11 +45,11 @@ class EmulatorTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
out_path = self.temp_dir
base_path = self.temp_dir
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -107,11 +107,11 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
out_path = os.path.join(self.temp_dir, "out")
base_path = os.path.join(self.temp_dir, "out")
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -134,13 +134,13 @@ class ArgumentsTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
out_path = self.temp_dir
base_path = self.temp_dir
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -182,6 +182,7 @@ class ArgumentsTestCase(test.CdistTestCase):
object_id = 'some-id'
value = 'some value'
argv = [type_name, object_id, '--required1', value, '--required2', value]
print(self.env)
os.environ.update(self.env)
emu = emulator.Emulator(argv)
emu.run()
@ -226,11 +227,11 @@ class StdinTestCase(test.CdistTestCase):
os.environ = os.environ.copy()
self.temp_dir = self.mkdtemp()
out_path = os.path.join(self.temp_dir, "out")
base_path = os.path.join(self.temp_dir, "out")
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -39,25 +39,25 @@ conf_dir = op.join(fixtures, "conf")
class ExplorerClassTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
self.temp_dir = self.mkdtemp()
self.out_path = os.path.join(self.temp_dir, "out")
self.local_path = os.path.join(self.temp_dir, "local")
self.remote_base_path = os.path.join(self.temp_dir, "remote")
os.makedirs(self.remote_base_path)
self.local = local.Local(
target_host=self.target_host,
out_path=self.out_path,
base_path=self.local_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
add_conf_dirs=[conf_dir],
)
self.local.create_files_dirs()
self.remote = remote.Remote(
self.target_host,
self.remote_exec,
self.remote_copy)
target_host=self.target_host,
remote_exec=self.remote_exec,
remote_copy=self.remote_copy,
base_path=self.remote_base_path)
self.remote.create_files_dirs()
self.explorer = explorer.Explorer(

View file

@ -46,11 +46,11 @@ class ManifestTestCase(test.CdistTestCase):
self.orig_environ = os.environ
os.environ = os.environ.copy()
self.temp_dir = self.mkdtemp()
self.target_host = 'localhost'
out_path = self.temp_dir
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=out_path,
exec_path = cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -78,7 +78,7 @@ class ManifestTestCase(test.CdistTestCase):
output_dict[key] = value
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__cdist_type_base_path'], self.local.type_path)
self.assertEqual(output_dict['__manifest'], self.local.manifest_path)
@ -99,7 +99,7 @@ class ManifestTestCase(test.CdistTestCase):
output_dict[key] = value
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__cdist_type_base_path'], self.local.type_path)
self.assertEqual(output_dict['__type'], cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], cdist_object.absolute_path)