コード例 #1
0
ファイル: test_views.py プロジェクト: TeachAtTUM/edx-platform
    def setUp(self):
        """
        Create the test data.
        """
        super(CompletionBatchTestCase, self).setUp()
        self.url = reverse('completion_api:v1:completion-batch')

        # Enable the waffle flag for all tests
        self.override_waffle_switch(True)

        # Create course
        self.course = CourseFactory.create(org='TestX', number='101', display_name='Test')
        self.problem = ItemFactory.create(
            parent=self.course,
            category="problem",
            display_name="Test Problem",
        )
        update_course_structure(unicode(self.course.id))

        # Create users
        self.staff_user = UserFactory(is_staff=True)
        self.enrolled_user = UserFactory(username=self.ENROLLED_USERNAME)
        self.unenrolled_user = UserFactory(username=self.UNENROLLED_USERNAME)

        # Enrol one user in the course
        CourseEnrollmentFactory.create(user=self.enrolled_user, course_id=self.course.id)

        # Login the enrolled user by for all tests
        self.client = APIClient()
        self.client.force_authenticate(user=self.enrolled_user)
コード例 #2
0
    def setUp(self):
        """
        Create the test data.
        """
        super(CompletionBatchTestCase, self).setUp()
        self.url = reverse('completion_api:v1:completion-batch')

        # Enable the waffle flag for all tests
        self.override_waffle_switch(True)

        # Create course
        self.course = CourseFactory.create(org='TestX',
                                           number='101',
                                           display_name='Test')
        self.problem = ItemFactory.create(
            parent=self.course,
            category="problem",
            display_name="Test Problem",
        )
        update_course_structure(unicode(self.course.id))

        # Create users
        self.staff_user = UserFactory(is_staff=True)
        self.enrolled_user = UserFactory(username=self.ENROLLED_USERNAME)
        self.unenrolled_user = UserFactory(username=self.UNENROLLED_USERNAME)

        # Enrol one user in the course
        CourseEnrollmentFactory.create(user=self.enrolled_user,
                                       course_id=self.course.id)

        # Login the enrolled user by for all tests
        self.client = APIClient()
        self.client.force_authenticate(user=self.enrolled_user)
コード例 #3
0
ファイル: tests.py プロジェクト: HowestX/edx-platform
    def test_update_course_structure(self):
        """
        Test the actual task that orchestrates data generation and updating the database.
        """
        # Method requires string input
        course_id = self.course.id
        self.assertRaises(ValueError, update_course_structure, course_id)

        # Ensure a CourseStructure object is created
        structure = _generate_course_structure(course_id)
        update_course_structure(unicode(course_id))
        cs = CourseStructure.objects.get(course_id=course_id)
        self.assertEqual(cs.course_id, course_id)
        self.assertEqual(cs.structure, structure)
コード例 #4
0
    def test_update_course_structure(self):
        """
        Test the actual task that orchestrates data generation and updating the database.
        """
        # Method requires string input
        course_id = self.course.id
        self.assertRaises(ValueError, update_course_structure, course_id)

        # Ensure a CourseStructure object is created
        structure = _generate_course_structure(course_id)
        update_course_structure(unicode(course_id))
        cs = CourseStructure.objects.get(course_id=course_id)
        self.assertEqual(cs.course_id, course_id)
        self.assertEqual(cs.structure, structure)
コード例 #5
0
    def test_update_course_structure(self):
        """
        Test the actual task that orchestrates data generation and updating the database.
        """
        # Method requires string input
        course_id = self.course.id
        self.assertRaises(ValueError, update_course_structure, course_id)

        # Ensure a CourseStructure object is created
        expected_structure = _generate_course_structure(course_id)
        update_course_structure(unicode(course_id))
        structure = CourseStructure.objects.get(course_id=course_id)
        self.assertEqual(structure.course_id, course_id)
        self.assertEqual(structure.structure, expected_structure['structure'])
        self.assertEqual(structure.discussion_id_map.keys(), expected_structure['discussion_id_map'].keys())
        self.assertEqual(
            [unicode(value) for value in structure.discussion_id_map.values()],
            expected_structure['discussion_id_map'].values()
        )
コード例 #6
0
    def setUp(self):
        super(CourseStructureTests, self).setUp()

        # Ensure course structure exists for the course
        update_course_structure(unicode(self.course.id))
コード例 #7
0
ファイル: tests.py プロジェクト: CraftAcademy/edx-platform
    def setUp(self):
        super(CourseStructureTests, self).setUp()

        # Ensure course structure exists for the course
        update_course_structure(unicode(self.course.id))