diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-30 11:35:46 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-01-17 10:44:14 -0500 |
commit | 45c7bbf24ae3c6530f33ebb33c062818ad44816d (patch) | |
tree | d39fbacaae2d712fdf250a9bce19f9737392539e /testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py | |
parent | a6b269011b2f1e84c650239065e56778591f087e (diff) | |
download | bcfg2-45c7bbf24ae3c6530f33ebb33c062818ad44816d.tar.gz bcfg2-45c7bbf24ae3c6530f33ebb33c062818ad44816d.tar.bz2 bcfg2-45c7bbf24ae3c6530f33ebb33c062818ad44816d.zip |
added a module-level FAM object to avoid passing it as an argument a billion times
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py')
-rw-r--r-- | testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py index 899fb24a0..2e1d6df51 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProbes.py @@ -16,6 +16,7 @@ while path != "/": break path = os.path.dirname(path) from common import * +from Bcfg2.Server.FileMonitor import _FAM from Bcfg2.Server.Plugins.Probes import * from TestPlugin import TestEntrySet, TestProbing, TestConnector, \ TestDatabaseBacked @@ -91,22 +92,23 @@ class TestProbeSet(TestEntrySet): ignore = ["foo~", ".#foo", ".foo.swp", ".foo.swx", "probed.xml"] bogus_names = ["test.py"] - def get_obj(self, path=datastore, fam=None, encoding=None, + def get_obj(self, path=datastore, encoding=None, plugin_name="Probes", basename=None): # get_obj() accepts the basename argument, accepted by the # parent get_obj() method, and just throws it away, since # ProbeSet uses a regex for the "basename" - if fam is None: - fam = Mock() - rv = self.test_obj(path, fam, encoding, plugin_name) + rv = self.test_obj(path, encoding, plugin_name) rv.entry_type = MagicMock() return rv def test__init(self): - fam = Mock() - ps = self.get_obj(fam=fam) + fam = Bcfg2.Server.FileMonitor._FAM + Bcfg2.Server.FileMonitor._FAM = Mock() + ps = self.get_obj() self.assertEqual(ps.plugin_name, "Probes") - fam.AddMonitor.assert_called_with(datastore, ps) + Bcfg2.Server.FileMonitor._FAM.AddMonitor.assert_called_with(datastore, + ps) + Bcfg2.Server.FileMonitor._FAM = fam TestEntrySet.test__init(self) def test_HandleEvent(self): @@ -256,9 +258,9 @@ text def test__init(self): mock_load_data = Mock() probes = self.get_probes_object(load_data=mock_load_data) - probes.core.fam.AddMonitor.assert_called_with(os.path.join(datastore, - probes.name), - probes.probes) + _FAM.AddMonitor.assert_called_with(os.path.join(datastore, + probes.name), + probes.probes) mock_load_data.assert_any_call() self.assertEqual(probes.probedata, ClientProbeDataSet()) self.assertEqual(probes.cgroups, dict()) |