fix some tests and fix home_dir lookup
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
1177286d4e
commit
69a3844332
2 changed files with 16 additions and 10 deletions
|
@ -54,7 +54,7 @@ class Local(object):
|
||||||
|
|
||||||
def _init_home_dir(self):
|
def _init_home_dir(self):
|
||||||
if 'HOME' in os.environ:
|
if 'HOME' in os.environ:
|
||||||
self.home_dir = os.environ['HOME']
|
self.home_dir = os.path.join(os.environ['HOME'], ".cdist")
|
||||||
else:
|
else:
|
||||||
self.home_dir = None
|
self.home_dir = None
|
||||||
|
|
||||||
|
|
|
@ -58,14 +58,8 @@ class LocalTestCase(test.CdistTestCase):
|
||||||
def test_cache_path(self):
|
def test_cache_path(self):
|
||||||
self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache"))
|
self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache"))
|
||||||
|
|
||||||
def test_global_explorer_path(self):
|
def test_conf_path(self):
|
||||||
self.assertEqual(self.local.global_explorer_path, os.path.join(self.base_path, "conf", "explorer"))
|
self.assertEqual(self.local.conf_path, os.path.join(self.out_path, "conf"))
|
||||||
|
|
||||||
def test_manifest_path(self):
|
|
||||||
self.assertEqual(self.local.manifest_path, os.path.join(self.base_path, "conf", "manifest"))
|
|
||||||
|
|
||||||
def test_type_path(self):
|
|
||||||
self.assertEqual(self.local.type_path, os.path.join(self.base_path, "conf", "type"))
|
|
||||||
|
|
||||||
def test_out_path(self):
|
def test_out_path(self):
|
||||||
self.assertEqual(self.local.out_path, self.out_path)
|
self.assertEqual(self.local.out_path, self.out_path)
|
||||||
|
@ -81,6 +75,18 @@ class LocalTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
### /test api
|
### /test api
|
||||||
|
|
||||||
|
### test internal implementation
|
||||||
|
|
||||||
|
def test_global_explorer_path(self):
|
||||||
|
self.assertEqual(self.local.global_explorer_path, os.path.join(self.out_path, "conf", "explorer"))
|
||||||
|
|
||||||
|
def test_manifest_path(self):
|
||||||
|
self.assertEqual(self.local.manifest_path, os.path.join(self.out_path, "conf", "manifest"))
|
||||||
|
|
||||||
|
def test_type_path(self):
|
||||||
|
self.assertEqual(self.local.type_path, os.path.join(self.out_path, "conf", "type"))
|
||||||
|
|
||||||
|
### other tests
|
||||||
|
|
||||||
def test_run_success(self):
|
def test_run_success(self):
|
||||||
self.local.run(['/bin/true'])
|
self.local.run(['/bin/true'])
|
||||||
|
@ -98,7 +104,7 @@ class LocalTestCase(test.CdistTestCase):
|
||||||
handle, script = self.mkstemp(dir=self.temp_dir)
|
handle, script = self.mkstemp(dir=self.temp_dir)
|
||||||
with os.fdopen(handle, "w") as fd:
|
with os.fdopen(handle, "w") as fd:
|
||||||
fd.writelines(["#!/bin/sh\n", "/bin/false"])
|
fd.writelines(["#!/bin/sh\n", "/bin/false"])
|
||||||
self.assertRaises(local.LocalScriptError, self.local.run_script, script)
|
self.assertRaises(cdist.Error, self.local.run_script, script)
|
||||||
|
|
||||||
def test_run_script_get_output(self):
|
def test_run_script_get_output(self):
|
||||||
handle, script = self.mkstemp(dir=self.temp_dir)
|
handle, script = self.mkstemp(dir=self.temp_dir)
|
||||||
|
|
Loading…
Reference in a new issue