From 5b66845d01a507120503c19e40829c6394d47b93 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 30 Aug 2013 11:35:57 -0400 Subject: XMLFileBacked: always watch xincludes In Bcfg2 1.3, XInclude'd files only got FAM watches if the parent file was monitoring itself, and it got a FAM object passed to it. This led to some ugly workarounds, and bugs -- you couldn't easily use XInclude in Properties or Bundler, for instance, and have changes recognized. Since FAM objects are now module-level, we can always monitor XInclude'd files. --- src/lib/Bcfg2/Server/Plugin/helpers.py | 7 ++----- .../Testlib/TestServer/TestPlugin/Testhelpers.py | 18 +++++------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py index 38491b05d..7a3d887fe 100644 --- a/src/lib/Bcfg2/Server/Plugin/helpers.py +++ b/src/lib/Bcfg2/Server/Plugin/helpers.py @@ -597,17 +597,14 @@ class XMLFileBacked(FileBacked): Index.__doc__ = FileBacked.Index.__doc__ def add_monitor(self, fpath): - """ Add a FAM monitor to a file that has been XIncluded. This - is only done if the constructor got both a ``fam`` object and - ``should_monitor`` set to True. + """ Add a FAM monitor to a file that has been XIncluded. :param fpath: The full path to the file to monitor :type fpath: string :returns: None """ self.extra_monitors.append(fpath) - if self.should_monitor: - self.fam.AddMonitor(fpath, self) + self.fam.AddMonitor(fpath, self) def __iter__(self): return iter(self.entries) diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py index c339b9e1d..dbab60abc 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py @@ -606,19 +606,11 @@ class TestXMLFileBacked(TestFileBacked): xfb.add_monitor("/test/test2.xml") self.assertIn("/test/test2.xml", xfb.extra_monitors) - if self.should_monitor is not True: - xfb = self.get_obj() - xfb.fam = Mock() - xfb.add_monitor("/test/test3.xml") - self.assertFalse(xfb.fam.AddMonitor.called) - self.assertIn("/test/test3.xml", xfb.extra_monitors) - - if self.should_monitor is not False: - xfb = self.get_obj(should_monitor=True) - xfb.fam = Mock() - xfb.add_monitor("/test/test4.xml") - xfb.fam.AddMonitor.assert_called_with("/test/test4.xml", xfb) - self.assertIn("/test/test4.xml", xfb.extra_monitors) + xfb = self.get_obj() + xfb.fam = Mock() + xfb.add_monitor("/test/test4.xml") + xfb.fam.AddMonitor.assert_called_with("/test/test4.xml", xfb) + self.assertIn("/test/test4.xml", xfb.extra_monitors) class TestStructFile(TestXMLFileBacked): -- cgit v1.2.3-1-g7c22