def test_delete_journal_issues_calls_remove_issue_from_journal(self): self.request.matchdict["journal_id"] = "1678-4596-cr" self.request.validated = {"issue": "1678-4596-cr-25-3"} MockRemoveIssueFromJournal = Mock() self.request.services[ "remove_issue_from_journal"] = MockRemoveIssueFromJournal restfulapi.delete_journal_issues(self.request) MockRemoveIssueFromJournal.assert_called_once_with( id="1678-4596-cr", issue="1678-4596-cr-25-3")
def test_delete_journal_issues_returns_204_if_ok(self): self.request.matchdict["journal_id"] = "1678-4596-cr" self.request.validated = {"issue": "1678-4596-cr-25-3"} MockRemoveIssueFromJournal = Mock() self.request.services[ "remove_issue_from_journal"] = MockRemoveIssueFromJournal response = restfulapi.delete_journal_issues(self.request) self.assertIsInstance(response, HTTPNoContent)
def test_delete_journal_issues_returns_404_if_no_journal_nor_issue_found( self): self.request.matchdict["journal_id"] = "1678-4596-cr" self.request.validated = {"issue": "1678-4596-cr-25-3"} MockRemoveIssueFromJournal = Mock( side_effect=exceptions.DoesNotExist("Does Not Exist")) self.request.services[ "remove_issue_from_journal"] = MockRemoveIssueFromJournal response = restfulapi.delete_journal_issues(self.request) self.assertIsInstance(response, HTTPNotFound)