cleanups of tests (especially exec.local)
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
6ecfb28d93
commit
1177286d4e
2 changed files with 16 additions and 16 deletions
|
@ -1,6 +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)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -25,9 +26,6 @@ import shutil
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
|
|
||||||
#import logging
|
|
||||||
#logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s')
|
|
||||||
|
|
||||||
import cdist
|
import cdist
|
||||||
from cdist import test
|
from cdist import test
|
||||||
from cdist.exec import local
|
from cdist.exec import local
|
||||||
|
@ -35,17 +33,22 @@ from cdist.exec import local
|
||||||
import os.path as op
|
import os.path as op
|
||||||
my_dir = op.abspath(op.dirname(__file__))
|
my_dir = op.abspath(op.dirname(__file__))
|
||||||
fixtures = op.join(my_dir, 'fixtures')
|
fixtures = op.join(my_dir, 'fixtures')
|
||||||
local_base_path = fixtures
|
|
||||||
|
|
||||||
|
|
||||||
class LocalTestCase(test.CdistTestCase):
|
class LocalTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp_dir = self.mkdtemp()
|
|
||||||
target_host = 'localhost'
|
target_host = 'localhost'
|
||||||
|
self.temp_dir = self.mkdtemp()
|
||||||
self.out_path = self.temp_dir
|
self.out_path = self.temp_dir
|
||||||
self.base_path = local_base_path
|
|
||||||
self.local = local.Local(target_host, self.base_path, self.out_path)
|
self.local = local.Local(
|
||||||
|
target_host=target_host,
|
||||||
|
out_path=self.out_path,
|
||||||
|
exec_path=test.cdist_exec_path
|
||||||
|
)
|
||||||
|
|
||||||
|
self.home_dir = os.path.join(os.environ['HOME'], ".cdist")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self.temp_dir)
|
shutil.rmtree(self.temp_dir)
|
||||||
|
@ -53,10 +56,7 @@ class LocalTestCase(test.CdistTestCase):
|
||||||
### test api
|
### test api
|
||||||
|
|
||||||
def test_cache_path(self):
|
def test_cache_path(self):
|
||||||
self.assertEqual(self.local.cache_path, os.path.join(self.base_path, "cache"))
|
self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache"))
|
||||||
|
|
||||||
def test_conf_path(self):
|
|
||||||
self.assertEqual(self.local.conf_path, os.path.join(self.base_path, "conf"))
|
|
||||||
|
|
||||||
def test_global_explorer_path(self):
|
def test_global_explorer_path(self):
|
||||||
self.assertEqual(self.local.global_explorer_path, os.path.join(self.base_path, "conf", "explorer"))
|
self.assertEqual(self.local.global_explorer_path, os.path.join(self.base_path, "conf", "explorer"))
|
||||||
|
@ -117,7 +117,8 @@ class LocalTestCase(test.CdistTestCase):
|
||||||
self.local.rmdir(temp_dir)
|
self.local.rmdir(temp_dir)
|
||||||
self.assertFalse(os.path.isdir(temp_dir))
|
self.assertFalse(os.path.isdir(temp_dir))
|
||||||
|
|
||||||
def test_create_directories(self):
|
def test_create_files_dirs(self):
|
||||||
self.local.create_directories()
|
self.local.create_files_dirs()
|
||||||
self.assertTrue(os.path.isdir(self.local.out_path))
|
self.assertTrue(os.path.isdir(self.local.out_path))
|
||||||
self.assertTrue(os.path.isdir(self.local.bin_path))
|
self.assertTrue(os.path.isdir(self.local.bin_path))
|
||||||
|
self.assertTrue(os.path.isdir(self.local.conf_path))
|
||||||
|
|
|
@ -49,8 +49,7 @@ class ManifestTestCase(test.CdistTestCase):
|
||||||
self.target_host = 'localhost'
|
self.target_host = 'localhost'
|
||||||
out_path = self.temp_dir
|
out_path = self.temp_dir
|
||||||
self.local = local.Local(self.target_host, local_base_path, out_path)
|
self.local = local.Local(self.target_host, local_base_path, out_path)
|
||||||
self.local.create_directories()
|
self.local.create_files_dirs()
|
||||||
self.local.link_emulator(cdist.test.cdist_exec_path)
|
|
||||||
self.manifest = manifest.Manifest(self.target_host, self.local)
|
self.manifest = manifest.Manifest(self.target_host, self.local)
|
||||||
self.log = logging.getLogger(self.target_host)
|
self.log = logging.getLogger(self.target_host)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue