From 1177286d4e678547bc1df228e4e97008fe12551f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 1 Nov 2012 14:42:55 +0100 Subject: [PATCH] cleanups of tests (especially exec.local) Signed-off-by: Nico Schottelius --- cdist/test/exec/local.py | 29 +++++++++++++++-------------- cdist/test/manifest/__init__.py | 3 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cdist/test/exec/local.py b/cdist/test/exec/local.py index e6f2c2b0..ebfc64af 100644 --- a/cdist/test/exec/local.py +++ b/cdist/test/exec/local.py @@ -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)) diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py index a9846b1d..61a815a9 100644 --- a/cdist/test/manifest/__init__.py +++ b/cdist/test/manifest/__init__.py @@ -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)