def test_get_department_not_exist(self, mock_get_department, mock_abort): """Api should return information about department.""" mock_get_department.return_value = None Department.get(1) mock_abort.assert_called_once_with( 404, message="No such department with ID=1")
def test_get_department_wrong_id_case2(self, mock_get_department, mock_abort): """Api should return error message if id have wrong format.""" mock_get_department.return_value = None Department.get(1.0) mock_abort.assert_called_once_with( 404, message="No such department with ID=1.0")
def test_get_department(self, mock_get_department): """Api should return information about department.""" mock_get_department.return_value = self.valid_test_data[0] response = Department.get(1) self.assertEqual(response.status_code, 200) self.assertEqual(response.json['department_id'], self.valid_test_data[0]['department_id']) self.assertEqual(response.json['manager'], self.valid_test_data[0]['manager']) self.assertEqual(response.json['date_of_creation'], self.valid_test_data[0]['date_of_creation']) self.assertEqual(response.json['employees'], self.valid_test_data[0]['employees']) self.assertEqual(response.json['department_avg_salary'], self.valid_test_data[0]['department_avg_salary']) self.assertEqual(response.json['name'], self.valid_test_data[0]['name'])
def test_get_department_wrong_id_case1(self, mock_abort): """Api should return error message if id have wrong format.""" Department.get('one') mock_abort.assert_called_once_with( 404, message="No such department with ID=one")