cleanups of tests (especially exec.local)

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-11-01 14:42:55 +01:00
parent 6ecfb28d93
commit 1177286d4e
2 changed files with 16 additions and 16 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -25,9 +26,6 @@ import shutil
import string
import random
#import logging
#logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s')
import cdist
from cdist import test
from cdist.exec import local
@ -35,17 +33,22 @@ from cdist.exec import local
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
local_base_path = fixtures
class LocalTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
target_host = 'localhost'
self.temp_dir = self.mkdtemp()
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):
shutil.rmtree(self.temp_dir)
@ -53,10 +56,7 @@ class LocalTestCase(test.CdistTestCase):
### test api
def test_cache_path(self):
self.assertEqual(self.local.cache_path, os.path.join(self.base_path, "cache"))
def test_conf_path(self):
self.assertEqual(self.local.conf_path, os.path.join(self.base_path, "conf"))
self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache"))
def test_global_explorer_path(self):
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.assertFalse(os.path.isdir(temp_dir))
def test_create_directories(self):
self.local.create_directories()
def test_create_files_dirs(self):
self.local.create_files_dirs()
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.conf_path))

View file

@ -49,8 +49,7 @@ class ManifestTestCase(test.CdistTestCase):
self.target_host = 'localhost'
out_path = self.temp_dir
self.local = local.Local(self.target_host, local_base_path, out_path)
self.local.create_directories()
self.local.link_emulator(cdist.test.cdist_exec_path)
self.local.create_files_dirs()
self.manifest = manifest.Manifest(self.target_host, self.local)
self.log = logging.getLogger(self.target_host)