def test_review_vertical_url(self):
        """
        Verify that the URL returned from the Review xBlock is a valid and
        correct URL for the vertical the learner has seen.
        """
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has problems and thus a vertical in the CSM
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.name,
                'section': self.section1_actual.location.name,
            }
        ))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_url = get_review_ids.get_vertical(self.course_actual.id)

        expected_url = self.URL_BEGINNING + 'vertical+block@New_Unit_1'

        self.assertEqual(result_url, expected_url)
    def test_review_vertical_url(self):
        """
        Verify that the URL returned from the Review xBlock is a valid and
        correct URL for the vertical the learner has seen.
        """
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has problems and thus a vertical in the CSM
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.name,
                        'section': self.section1_actual.location.name,
                    }))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_url = get_review_ids.get_vertical(self.course_actual.id)

        expected_url = self.URL_BEGINNING + 'vertical+block@New_Unit_1'

        self.assertEqual(result_url, expected_url)
    def test_review_problem_urls(self, num_desired):
        """
        Verify that the URLs returned from the Review xBlock are valid and
        correct URLs for the problems the learner has seen.
        """
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has enough problems in the CSM
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.block_id,
                'section': self.section1_actual.location.block_id,
            }
        ))
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.block_id,
                'section': self.section2_actual.location.block_id,
            }
        ))
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.block_id,
                'section': self.section3_actual.location.block_id,
            }
        ))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id)

        expected_urls = [
            (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0)
        ]

        # Since the problems are randomly selected, we have to check
        # the correct number of urls are returned.
        count = 0
        for url in expected_urls:
            if url in result_urls:
                count += 1
        self.assertEqual(count, num_desired)
    def test_review_problem_urls(self, num_desired):
        """
        Verify that the URLs returned from the Review xBlock are valid and
        correct URLs for the problems the learner has seen.
        """
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has enough problems in the CSM
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.block_id,
                        'section': self.section1_actual.location.block_id,
                    }))
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.block_id,
                        'section': self.section2_actual.location.block_id,
                    }))
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.block_id,
                        'section': self.section3_actual.location.block_id,
                    }))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_urls = get_review_ids.get_problems(num_desired,
                                                  self.course_actual.id)

        expected_urls = [
            (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0)
        ]

        # Since the problems are randomly selected, we have to check
        # the correct number of urls are returned.
        count = 0
        for url in expected_urls:
            if url in result_urls:
                count += 1
        self.assertEqual(count, num_desired)
    def test_review_problem_urls_unique_problem(self, num_desired):
        """
        Verify that the URLs returned from the Review xBlock are valid and
        correct URLs for the problems the learner has seen. This test will give
        a unique problem to a learner and verify only that learner sees
        it as a review. It will also ensure that if a learner has not loaded a
        problem, it should never show up as a review problem
        """
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'],
                            self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has enough problems in the CSM
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.block_id,
                        'section': self.section1_actual.location.block_id,
                    }))
        self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course_actual.id,
                        'chapter': self.chapter_actual.location.block_id,
                        'section': self.section3_actual.location.block_id,
                    }))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_urls = get_review_ids.get_problems(num_desired,
                                                  self.course_actual.id)

        expected_urls = [
            (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0),
            # This is the unique problem when num_desired == 5
            (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0)
        ]
        expected_not_loaded_problem = (self.URL_BEGINNING +
                                       'problem+block@Problem_5', True, 0)

        # Since the problems are randomly selected, we have to check
        # the correct number of urls are returned.
        count = 0
        for url in expected_urls:
            if url in result_urls:
                count += 1
        self.assertEqual(count, num_desired)
        self.assertNotIn(expected_not_loaded_problem, result_urls)
    def test_review_problem_urls_unique_problem(self, num_desired):
        """
        Verify that the URLs returned from the Review xBlock are valid and
        correct URLs for the problems the learner has seen. This test will give
        a unique problem to a learner and verify only that learner sees
        it as a review. It will also ensure that if a learner has not loaded a
        problem, it should never show up as a review problem
        """
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_actual)
        self.enroll_student(self.STUDENTS[0]['email'], self.STUDENTS[0]['password'], self.course_review)

        # Loading problems so the learner has enough problems in the CSM
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.block_id,
                'section': self.section1_actual.location.block_id,
            }
        ))
        self.client.get(reverse(
            'courseware_section',
            kwargs={
                'course_id': self.course_actual.id,
                'chapter': self.chapter_actual.location.block_id,
                'section': self.section3_actual.location.block_id,
            }
        ))

        user = User.objects.get(email=self.STUDENTS[0]['email'])
        crum.set_current_user(user)
        result_urls = get_review_ids.get_problems(num_desired, self.course_actual.id)

        expected_urls = [
            (self.URL_BEGINNING + 'problem+block@Problem_1', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_2', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_3', True, 0),
            (self.URL_BEGINNING + 'problem+block@Problem_4', True, 0),
            # This is the unique problem when num_desired == 5
            (self.URL_BEGINNING + 'problem+block@Problem_6', True, 0)
        ]
        expected_not_loaded_problem = (self.URL_BEGINNING + 'problem+block@Problem_5', True, 0)

        # Since the problems are randomly selected, we have to check
        # the correct number of urls are returned.
        count = 0
        for url in expected_urls:
            if url in result_urls:
                count += 1
        self.assertEqual(count, num_desired)
        self.assertNotIn(expected_not_loaded_problem, result_urls)
Exemple #7
0
def setup_data():
    user_model = apps.get_model("auth.user")
    user = user_model.objects.create(
        username=get_version_str(),
        email="*****@*****.**",
        first_name="The",
        last_name="Dude",
    )
    set_current_user(user)
    model = apps.get_model("rna.release")
    model.objects.create(
        product="Firefox",
        channel="Nightly",
        version=get_version_str(),
        release_date=now(),
    )
    return GithubLog.objects.latest()