def _assert_team_assessment(self, assessment, submission, expected_answer): """ Helper function to perform asserts """ self.assertEqual(assessment['points_earned'], expected_answer['points_earned']) self.assertEqual(assessment['scorer_id'], 'Bob') self.assertEqual(assessment['score_type'], 'ST') self.assertEqual(assessment['feedback'], 'Staff: good job!') parts = assessment['parts'] parts.sort(key=lambda x: x['option']['name']) self.assertEqual(len(parts), 3) self.assertEqual(parts[0]['option']['criterion']['name'], expected_answer['parts0_criterion_name']) self.assertEqual(parts[1]['option']['criterion']['name'], expected_answer['parts1_criterion_name']) self.assertEqual(parts[2]['option']['criterion']['name'], expected_answer['parts2_criterion_name']) self.assertEqual(parts[0]['option']['name'], expected_answer['parts0_option_name']) self.assertEqual(parts[1]['option']['name'], expected_answer['parts1_option_name']) self.assertEqual(parts[2]['option']['name'], expected_answer['parts2_option_name']) score = teams_api.get_score(submission['team_submission_uuid'], {}) self.assertEqual(assessment['points_earned'], score['points_earned']) self.assertEqual(assessment['points_possible'], score['points_possible'])
def test_get_score_none(self): # Given there's no assessment for a submission team_submission_uuid = self._create_test_submission_for_team()['team_submission_uuid'] staff_requirements = {'required': True} # When I use the API to get the score score = teams_api.get_score(team_submission_uuid, staff_requirements) # Then None is returned self.assertIsNone(score)
def test_get_score(self): # Given an assessment fora submission team_submission_uuid = self._create_test_submission_for_team()['team_submission_uuid'] assessments = self._create_test_assessments_for_team(team_submission_uuid) staff_requirements = {'required': True} # When I query the API for the score score = teams_api.get_score(team_submission_uuid, staff_requirements) # Then the score is returned (from test constants) assessment = assessments[-1] self.assertEqual(score, { "points_earned": assessment["points_earned"], "points_possible": assessment["points_possible"], "contributing_assessments": [assessment['id']], "staff_id": assessment["scorer_id"], })