diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-25 13:31:21 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-25 13:31:21 -0400 |
commit | 9c603d8267c0a511968a8a553d7fa0b2d5bf9b73 (patch) | |
tree | c473a7615586dc22d585bda67e118ed2fe535754 /testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py | |
parent | 3dc289678812238c2fcc54098b1d8de9bf64f900 (diff) | |
download | bcfg2-9c603d8267c0a511968a8a553d7fa0b2d5bf9b73.tar.gz bcfg2-9c603d8267c0a511968a8a553d7fa0b2d5bf9b73.tar.bz2 bcfg2-9c603d8267c0a511968a8a553d7fa0b2d5bf9b73.zip |
Handle FAM monitor failures more gracefully:
* Where possible, create the file or directory that is about to be
monitored. This ensures that content can be added later without
need to restart Bcfg2. (Otherwise, adding the monitor would fail,
and so when you did create the file in question, bcfg2-server would
never be notified of it.)
* When not possible, give better error messages.
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py')
-rw-r--r-- | testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py index 93e2fff51..896f5861e 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py @@ -418,8 +418,8 @@ class TestXMLPropertyFile(TestPropertyFile, TestStructFile): self.assertFalse(mock_copy.called) -class TestPropDirectoryBacked(TestDirectoryBacked): - test_obj = PropDirectoryBacked +class TestProperties(TestPlugin, TestConnector, TestDirectoryBacked): + test_obj = Properties testfiles = ['foo.xml', 'bar.baz.xml'] if HAS_JSON: testfiles.extend(["foo.json", "foo.xml.json"]) @@ -428,17 +428,13 @@ class TestPropDirectoryBacked(TestDirectoryBacked): ignore = ['foo.xsd', 'bar.baz.xsd', 'quux.xml.xsd'] badevents = ['bogus.txt'] - -class TestProperties(TestPlugin, TestConnector): - test_obj = Properties - - def test__init(self): - TestPlugin.test__init(self) - - core = Mock() - p = self.get_obj(core=core) - self.assertIsInstance(p.store, PropDirectoryBacked) - self.assertEqual(Bcfg2.Server.Plugins.Properties.SETUP, core.setup) + def get_obj(self, core=None): + @patch("%s.%s.add_directory_monitor" % (self.test_obj.__module__, + self.test_obj.__name__), + Mock()) + def inner(): + return TestPlugin.get_obj(self, core=core) + return inner() @patch("copy.copy") def test_get_additional_data(self, mock_copy): @@ -446,11 +442,11 @@ class TestProperties(TestPlugin, TestConnector): p = self.get_obj() metadata = Mock() - p.store.entries = {"foo.xml": Mock(), - "foo.yml": Mock()} + p.entries = {"foo.xml": Mock(), + "foo.yml": Mock()} rv = p.get_additional_data(metadata) expected = dict() - for name, entry in p.store.entries.items(): + for name, entry in p.entries.items(): entry.get_additional_data.assert_called_with(metadata) expected[name] = entry.get_additional_data.return_value self.assertItemsEqual(rv, expected) |