forked from ungleich-public/cdist
add test to verify code setups debug env
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
422800ab98
commit
dd05a9b0d7
1 changed files with 13 additions and 5 deletions
|
@ -24,6 +24,7 @@ import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
import shutil
|
import shutil
|
||||||
import getpass
|
import getpass
|
||||||
|
import logging
|
||||||
|
|
||||||
import cdist
|
import cdist
|
||||||
from cdist import core
|
from cdist import core
|
||||||
|
@ -46,25 +47,27 @@ class CodeTestCase(unittest.TestCase):
|
||||||
return tempfile.mkstemp(prefix='tmp.cdist.test.', **kwargs)
|
return tempfile.mkstemp(prefix='tmp.cdist.test.', **kwargs)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
target_host = 'localhost'
|
self.target_host = 'localhost'
|
||||||
|
|
||||||
self.local_base_path = local_base_path
|
self.local_base_path = local_base_path
|
||||||
self.out_path = self.mkdtemp()
|
self.out_path = self.mkdtemp()
|
||||||
self.local = local.Local(target_host, self.local_base_path, self.out_path)
|
self.local = local.Local(self.target_host, self.local_base_path, self.out_path)
|
||||||
self.local.create_directories()
|
self.local.create_directories()
|
||||||
|
|
||||||
self.remote_base_path = self.mkdtemp()
|
self.remote_base_path = self.mkdtemp()
|
||||||
self.user = getpass.getuser()
|
self.user = getpass.getuser()
|
||||||
remote_exec = "ssh -o User=%s -q" % self.user
|
remote_exec = "ssh -o User=%s -q" % self.user
|
||||||
remote_copy = "scp -o User=%s -q" % self.user
|
remote_copy = "scp -o User=%s -q" % self.user
|
||||||
self.remote = remote.Remote(target_host, self.remote_base_path, remote_exec, remote_copy)
|
self.remote = remote.Remote(self.target_host, self.remote_base_path, remote_exec, remote_copy)
|
||||||
|
|
||||||
self.code = code.Code(target_host, self.local, self.remote)
|
self.code = code.Code(self.target_host, self.local, self.remote)
|
||||||
|
|
||||||
self.cdist_type = core.Type(self.local.type_path, '__dump_environment')
|
self.cdist_type = core.Type(self.local.type_path, '__dump_environment')
|
||||||
self.cdist_object = core.Object(self.cdist_type, self.local.object_path, 'whatever')
|
self.cdist_object = core.Object(self.cdist_type, self.local.object_path, 'whatever')
|
||||||
self.cdist_object.create()
|
self.cdist_object.create()
|
||||||
|
|
||||||
|
self.log = logging.getLogger("cdist")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self.out_path)
|
shutil.rmtree(self.out_path)
|
||||||
shutil.rmtree(self.remote_base_path)
|
shutil.rmtree(self.remote_base_path)
|
||||||
|
@ -113,3 +116,8 @@ class CodeTestCase(unittest.TestCase):
|
||||||
self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object)
|
self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object)
|
||||||
self.code.transfer_code_remote(self.cdist_object)
|
self.code.transfer_code_remote(self.cdist_object)
|
||||||
self.code.run_code_remote(self.cdist_object)
|
self.code.run_code_remote(self.cdist_object)
|
||||||
|
|
||||||
|
def test_debug_env_setup(self):
|
||||||
|
self.log.setLevel(logging.DEBUG)
|
||||||
|
code = cdist.core.code.Code(self.target_host, self.local, self.remote)
|
||||||
|
self.assertTrue("__debug" in code.env)
|
||||||
|
|
Loading…
Reference in a new issue