From 6dd9756f7a87d5e875f5db02f306c7b906902a96 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 29 Oct 2013 10:21:12 -0400 Subject: Plugins: refactored out unnecessary datastore constructor argument --- .../Testlib/TestServer/TestPlugins/TestMetadata.py | 3 ++- .../Testlib/TestServer/TestPlugins/TestProbes.py | 26 ++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugins') 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() -- cgit v1.2.3-1-g7c22