summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-10-29 10:21:12 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-10-29 15:22:33 -0400
commit6dd9756f7a87d5e875f5db02f306c7b906902a96 (patch)
tree81ab5e948e9b2449609e260628d5d14f63f5a6cf /testsuite
parentaec12296330b121fcb3fd038f85c0a4590be8ce4 (diff)
downloadbcfg2-6dd9756f7a87d5e875f5db02f306c7b906902a96.tar.gz
bcfg2-6dd9756f7a87d5e875f5db02f306c7b906902a96.tar.bz2
bcfg2-6dd9756f7a87d5e875f5db02f306c7b906902a96.zip
Plugins: refactored out unnecessary datastore constructor argument
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py2
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py6
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py1
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py3
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py26
-rw-r--r--testsuite/common.py11
6 files changed, 26 insertions, 23 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py
index 9b55b3ae8..f135a0197 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testbase.py
@@ -29,7 +29,7 @@ class TestPlugin(TestDebuggable):
@patchIf(not isinstance(os.makedirs, Mock), "os.makedirs", Mock())
def inner():
- return self.test_obj(core, datastore)
+ return self.test_obj(core)
return inner()
@patch("os.makedirs")
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
index dbab60abc..81c4837e1 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
@@ -1180,7 +1180,7 @@ class TestPrioDir(TestPlugin, TestGenerator, TestXMLDirectoryBacked):
Mock())
@patchIf(not isinstance(os.makedirs, Mock), "os.makedirs", Mock())
def inner():
- return self.test_obj(core, datastore)
+ return self.test_obj(core)
return inner()
@@ -1416,7 +1416,7 @@ class TestEntrySet(TestDebuggable):
set_setup_default("default_paranoid", False)
set_setup_default("default_sensitive", False)
- def get_obj(self, basename="test", path=datastore, entry_type=MagicMock()):
+ def get_obj(self, basename="test", entry_type=MagicMock()):
return self.test_obj(basename, path, entry_type)
def test__init(self):
@@ -1791,7 +1791,7 @@ class TestGroupSpool(TestPlugin, TestGenerator):
@patch("%s.%s.AddDirectoryMonitor" % (self.test_obj.__module__,
self.test_obj.__name__))
def inner(mock_Add):
- gs = self.test_obj(MagicMock(), datastore)
+ gs = self.test_obj(MagicMock())
mock_Add.assert_called_with('')
self.assertItemsEqual(gs.Entries, {gs.entry_type: {}})
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py
index ac0454f84..bbfb495c4 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py
@@ -374,4 +374,3 @@ class TestClientACLs(Bcfg2TestCase):
ca = self.get_obj()
self.assertIn(ca.check_acl_metadata(Mock(), Mock()),
[True, False])
-
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
index 8814ae171..d3fa15236 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestMetadata.py
@@ -100,8 +100,9 @@ def get_metadata_object(core=None):
@patchIf(not isinstance(os.makedirs, Mock), "os.makedirs", Mock())
@patchIf(not isinstance(lxml.etree.Element, Mock),
"lxml.etree.Element", Mock())
+
def inner():
- return Metadata(core, datastore)
+ return Metadata(core)
return inner()
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
index 4830f9f2f..68313e6fb 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py
@@ -19,7 +19,7 @@ while path != "/":
path = os.path.dirname(path)
from common import *
from Bcfg2.Server.Plugins.Probes import load_django_models
-from TestPlugin import TestEntrySet, TestProbing, TestConnector, \
+from TestPlugin import TestEntrySet, TestPlugin, \
TestDatabaseBacked
load_django_models()
@@ -200,7 +200,7 @@ group-specific"""
assert False, "Strange probe found in get_probe_data() return"
-class TestProbes(Bcfg2TestCase):
+class TestProbes(TestPlugin):
test_obj = Probes
test_xdata = lxml.etree.Element("test")
@@ -236,21 +236,23 @@ group: group:with:colons
if self.datastore is not None:
shutil.rmtree(self.datastore)
self.datastore = None
+ Bcfg2.Options.setup.repository = datastore
- def get_obj(self, core=None):
- if core is None:
- core = Mock()
- if Bcfg2.Options.setup.probes_db:
- @patch("os.makedirs", Mock())
- def inner():
- return self.test_obj(core, datastore)
- return inner()
- else:
+ def get_obj(self):
+ if not Bcfg2.Options.setup.probes_db:
# actually use a real datastore so we can read and write
# probed.xml
if self.datastore is None:
self.datastore = tempfile.mkdtemp()
- return self.test_obj(core, self.datastore)
+ Bcfg2.Options.setup.repository = self.datastore
+ datadir = os.path.join(self.datastore, self.test_obj.name)
+ if not os.path.exists(datadir):
+ os.makedirs(datadir)
+ return TestPlugin.get_obj(self)
+
+ def test__init(self):
+ if Bcfg2.Options.setup.probes_db:
+ TestPlugin.test__init(self)
def test_GetProbes(self):
p = self.get_obj()
diff --git a/testsuite/common.py b/testsuite/common.py
index 04c446f67..49035a177 100644
--- a/testsuite/common.py
+++ b/testsuite/common.py
@@ -20,11 +20,6 @@ try:
except ImportError:
from unittest2 import skip, skipIf, skipUnless, TestCase
-#: The path to the Bcfg2 specification root for the tests. Using the
-#: root directory exposes a lot of potential problems with building
-#: paths.
-datastore = "/"
-
#: The XInclude namespace name
XI_NAMESPACE = "http://www.w3.org/2001/XInclude"
@@ -68,6 +63,12 @@ try:
except ImportError:
has_django = False
+#: The path to the Bcfg2 specification root for the tests. Using the
+#: root directory exposes a lot of potential problems with building
+#: paths.
+datastore = "/"
+
+set_setup_default("repository", datastore)
try:
from mock import call