def assertValidContext(self, context): # We intentionally do not call the superclass method since this page does not have # an assignments field in the context. expected = { 'assignment_types': self.factory.presented_assignment_types, 'grading_policy': self.factory.presented_grading_policy, } utils.assert_dict_contains_subset(context, expected)
def assertValidContext(self, context): super().assertValidContext(context) self.assertListEqual(context['assignment']['children'], self.assignment['children']) expected = { 'assignment_type': self.assignment_type, 'assignment': self.assignment, } utils.assert_dict_contains_subset(context, expected)
def assertValidContext(self, context): """ Validates the response context. This is intended to be validate the context of a VALID response returned by a view under normal conditions. """ expected = { 'assignment_types': self.factory.presented_assignment_types, 'assignments': self.factory.presented_assignments, 'no_data_message': 'No submissions received for these assignments.' } utils.assert_dict_contains_subset(context, expected)
def _assert_context(self, response, expected_context_subset): default_expected_context_subset = { 'learner_list_url': '/api/learner_analytics/v0/learners/', 'course_learner_metadata_url': '/api/learner_analytics/v0/course_learner_metadata/{course_id}/'.format( course_id=CourseSamples.DEMO_COURSE_ID ), } assert_dict_contains_subset(response.context, dict(list(expected_context_subset.items()))) assert_dict_contains_subset( response.context['js_data']['course'], dict(list(default_expected_context_subset.items())), )
def assertViewIsValid(self, course_id, problem_id, problem_part_id): # Mock the answer distribution and retrieve the view rv = utils.get_presenter_answer_distribution(course_id, problem_part_id) with patch(self.presenter_method, return_value=rv): response = self.client.get( self.path(course_id=course_id, problem_id=problem_id, problem_part_id=problem_part_id)) context = response.context # Ensure we get a valid HTTP status self.assertEqual(response.status_code, 200) self.assertValidContext(response.context) self.assertListEqual(context['questions'], rv.questions) utils.assert_dict_contains_subset( context, { 'page_title': 'Performance: Problem Submissions', 'problem_id': problem_id, 'problem_part_id': problem_part_id, 'view_live_url': '{}/{}/jump_to/{}'.format( settings.LMS_COURSE_SHORTCUT_BASE_URL, course_id, problem_id), 'active_question': rv.active_question, 'questions': rv.questions }, ) utils.assert_dict_contains_subset( json.loads(context['page_data'])['course'], { 'isRandom': rv.is_random, 'answerType': rv.answer_type, 'answerDistribution': rv.answer_distribution, 'answerDistributionLimited': rv.answer_distribution_limited, }, ) self.assertPrimaryNav(response.context['primary_nav_item'], course_id) self.assertSecondaryNavs(response.context['secondary_nav_items'], course_id)
def assertValidContext(self, context): expected = { 'sections': self.sections, 'no_data_message': 'No submissions received for these exercises.' } utils.assert_dict_contains_subset(context, expected)
def assertValidContext(self, context): expected = { 'sections': self.sections, } utils.assert_dict_contains_subset(context, expected)