def test_get_should_throw_404_error_if_job_posting_does_not_exist( self, mock_get, mock_session): mock_get.return_value = None with self.assertRaises(HTTPException) as ex: JobPostingHandler.get(self.test_job_posting.id) self.assertEqual(ex.exception.code, 404) mock_get.assert_called_once_with(mock.ANY, self.test_job_posting.id)
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_get_should_return_json_string_of_job_posting( self, mock_get, mock_session): mock_get.return_value = self.test_job_posting result, code, header = JobPostingHandler.get(self.test_job_posting.id) self.assertEqual( self.test_job_posting, json.loads(result, object_hook=lambda d: JobPosting(**d))) mock_get.assert_called_once_with(mock.ANY, self.test_job_posting.id) self.assertEqual(200, code) self.assertEqual({'Content-Type': 'application/json'}, header)
def test_update_should_throw_400_error_if_job_posting_id_is_null(self): with self.assertRaises(HTTPException) as ex: JobPostingHandler.update(None) self.assertEqual(ex.exception.code, 400)
def delete(job_posting_id): return JobPostingHandler.delete(job_posting_id)
def update(job_posting_id): return JobPostingHandler.update(job_posting_id, **request.get_json())
def create(): return JobPostingHandler.create(**request.get_json())
def get(job_posting_id): return JobPostingHandler.get(job_posting_id)