def test_HandlesEntry(self): modules = self.get_obj() modules._get_module_filename = Mock() modules.Entries['SEModule']['/foo.pp'] = Mock() modules.Entries['SEModule']['/bar.pp'] = Mock() for el in [ lxml.etree.Element("Path", name="foo.pp"), lxml.etree.Element("SEModule", name="baz.pp") ]: modules._get_module_filename.return_value = "/" + el.get("name") self.assertFalse(modules.HandlesEntry(el, Mock())) if el.tag == "SEModule": modules._get_module_filename.assert_called_with(el) for el in [ lxml.etree.Element("SEModule", name="foo.pp"), lxml.etree.Element("SEModule", name="bar.pp") ]: modules._get_module_filename.return_value = "/" + el.get("name") self.assertTrue(modules.HandlesEntry(el, Mock()), msg="SEModules fails to handle %s" % el.get("name")) modules._get_module_filename.assert_called_with(el) TestGroupSpool.test_HandlesEntry(self)
def test_HandlesEntry(self, mock_get_name): modules = self.get_obj() handler = Mock() modules.Entries['SELinux']['/foo.pp'] = handler mock_get_name.return_value = "/foo.pp" entry = lxml.etree.Element("SELinux", type="module", name="foo") metadata = Mock() self.assertEqual(modules.HandleEntry(entry, metadata), handler.return_value) mock_get_name.assert_called_with(entry) self.assertEqual(entry.get("name"), mock_get_name.return_value) handler.assert_called_with(entry, metadata) TestGroupSpool.test_HandlesEntry(self)
def test_HandleEntry(self): modules = self.get_obj() modules._get_module_name = Mock() handler = Mock() modules.Entries['SEModule']['/foo.pp'] = handler modules._get_module_name.return_value = "foo" entry = lxml.etree.Element("SEModule", type="module", name="foo") metadata = Mock() self.assertEqual(modules.HandleEntry(entry, metadata), handler.return_value) modules._get_module_name.assert_called_with(entry) self.assertEqual(entry.get("name"), modules._get_module_name.return_value) handler.assert_called_with(entry, metadata) TestGroupSpool.test_HandlesEntry(self)
def test_HandlesEntry(self): modules = self.get_obj() modules._get_module_filename = Mock() modules.Entries['SEModule']['/foo.pp'] = Mock() modules.Entries['SEModule']['/bar.pp'] = Mock() for el in [lxml.etree.Element("Path", name="foo.pp"), lxml.etree.Element("SEModule", name="baz.pp")]: modules._get_module_filename.return_value = "/" + el.get("name") self.assertFalse(modules.HandlesEntry(el, Mock())) if el.tag == "SEModule": modules._get_module_filename.assert_called_with(el) for el in [lxml.etree.Element("SEModule", name="foo.pp"), lxml.etree.Element("SEModule", name="bar.pp")]: modules._get_module_filename.return_value = "/" + el.get("name") self.assertTrue(modules.HandlesEntry(el, Mock()), msg="SEModules fails to handle %s" % el.get("name")) modules._get_module_filename.assert_called_with(el) TestGroupSpool.test_HandlesEntry(self)
def test_HandlesEntry(self, mock_get_name): modules = self.get_obj() modules.Entries['SELinux']['/foo.pp'] = Mock() modules.Entries['SELinux']['/bar.pp'] = Mock() for el in [lxml.etree.Element("Path", name="/foo.pp"), lxml.etree.Element("SELinux", type="fcontext", name="/foo.pp"), lxml.etree.Element("SELinux", type="module", name="/baz.pp")]: mock_get_name.return_value = el.get("name") self.assertFalse(modules.HandlesEntry(el, Mock())) mock_get_name.assert_called_with(el) for el in [lxml.etree.Element("SELinux", type="module", name="/foo.pp"), lxml.etree.Element("SELinux", type="module", name="/bar.pp")]: mock_get_name.return_value = el.get("name") self.assertTrue(modules.HandlesEntry(el, Mock()), msg="SEModules fails to handle %s" % el.get("name")) mock_get_name.assert_called_with(el) TestGroupSpool.test_HandlesEntry(self)