def test_delete_should_throw_500_error_if_deleting_fails( self, mock_delete, mock_session): mock_delete.return_value = None with self.assertRaises(HTTPException) as ex: JobPostingHandler.delete(self.test_job_posting.id) self.assertEqual(ex.exception.code, 500) mock_delete.assert_called_once_with(mock.ANY, self.test_job_posting.id)
def test_delete_should_return_json_string_of_job_posting( self, mock_delete, mock_session): mock_delete.return_value = self.test_job_posting result, code, header = JobPostingHandler.delete( self.test_job_posting.id) self.assertEqual( self.test_job_posting, json.loads(result, object_hook=lambda d: JobPosting(**d))) mock_delete.assert_called_once_with(mock.ANY, self.test_job_posting.id) self.assertEqual(200, code) self.assertEqual({'Content-Type': 'application/json'}, header)
def test_delete_should_throw_400_error_if_job_posting_id_is_null(self): with self.assertRaises(HTTPException) as ex: JobPostingHandler.delete(None) self.assertEqual(ex.exception.code, 400)
def delete(job_posting_id): return JobPostingHandler.delete(job_posting_id)