def test_install(self, mock_rmtree, mock_isdir, mock_remove, mock_rmdir): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") def reset(): mock_isdir.reset_mock() mock_remove.reset_mock() mock_rmdir.reset_mock() mock_rmtree.reset_mock() mock_isdir.return_value = False self.assertTrue(self.ptool.install(entry)) mock_remove.assert_called_with(entry.get("name")) reset() mock_remove.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_remove.assert_called_with(entry.get("name")) reset() mock_isdir.return_value = True self.assertTrue(self.ptool.install(entry)) mock_rmdir.assert_called_with(entry.get("name")) reset() mock_rmdir.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_rmdir.assert_called_with(entry.get("name")) reset() entry.set("recursive", "true") self.assertTrue(self.ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() mock_rmtree.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="nonexistent") ptool = self.get_obj(posix=get_posix_object( config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertTrue(ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="file") ptool = self.get_obj(posix=get_posix_object( config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertFalse(ptool.install(entry))
def test_install(self, mock_rmtree, mock_isdir, mock_remove, mock_rmdir): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") def reset(): mock_isdir.reset_mock() mock_remove.reset_mock() mock_rmdir.reset_mock() mock_rmtree.reset_mock() mock_isdir.return_value = False self.assertTrue(self.ptool.install(entry)) mock_remove.assert_called_with(entry.get("name")) reset() mock_remove.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_remove.assert_called_with(entry.get("name")) reset() mock_isdir.return_value = True self.assertTrue(self.ptool.install(entry)) mock_rmdir.assert_called_with(entry.get("name")) reset() mock_rmdir.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_rmdir.assert_called_with(entry.get("name")) reset() entry.set("recursive", "true") self.assertTrue(self.ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() mock_rmtree.side_effect = OSError self.assertFalse(self.ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="nonexistent") ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertTrue(ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="file") ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertFalse(ptool.install(entry))
def test_install(self): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") ptool = self.get_obj() ptool._remove = Mock() def reset(): ptool._remove.reset_mock() self.assertTrue(ptool.install(entry)) ptool._remove.assert_called_with(entry, recursive=False) reset() entry.set("recursive", "true") self.assertTrue(ptool.install(entry)) ptool._remove.assert_called_with(entry, recursive=True) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="nonexistent") ptool = self.get_obj(config=get_config([child_entry])) ptool._remove = Mock() self.assertTrue(ptool.install(entry)) ptool._remove.assert_called_with(entry, recursive=True) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="file") ptool = self.get_obj(config=get_config([child_entry])) ptool._remove = Mock() self.assertFalse(ptool.install(entry)) self.assertFalse(ptool._remove.called) reset() entry.set("recursive", "false") ptool._remove.side_effect = OSError self.assertFalse(ptool.install(entry)) ptool._remove.assert_called_with(entry, recursive=False)
def test_install(self): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") self.ptool._remove = Mock() def reset(): self.ptool._remove.reset_mock() self.assertTrue(self.ptool.install(entry)) self.ptool._remove.assert_called_with(entry, recursive=False) reset() entry.set("recursive", "true") self.assertTrue(self.ptool.install(entry)) self.ptool._remove.assert_called_with(entry, recursive=True) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="nonexistent") ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) ptool._remove = Mock() self.assertTrue(ptool.install(entry)) ptool._remove.assert_called_with(entry, recursive=True) reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="file") ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) ptool._remove = Mock() self.assertFalse(ptool.install(entry)) self.assertFalse(ptool._remove.called) reset() entry.set("recursive", "false") self.ptool._remove.side_effect = OSError self.assertFalse(self.ptool.install(entry)) self.ptool._remove.assert_called_with(entry, recursive=False)