def test_DeletePostWhenPostDAOThrows(self): postDAO = PostDAO(None) postDAO.delete = MagicMock(side_effect=UnknownElementException()) postController = PostController(postDAO) request = Request(None) deleteId = 3 response = postController.deletePost(deleteId, request) self.assertEqual(404, response.status_code) postDAO.delete.assert_called_with(deleteId)
def test_DeletePost(self): postDAO = PostDAO(None) postDAO.delete = MagicMock() postController = PostController(postDAO) request = Request(None) deleteId = "3" response = postController.deletePost(deleteId, request) self.assertEqual(204, response.status_code) postDAO.delete.assert_called_with(deleteId)