def test_course_constructor_version_guid(self):
        # generate a random location
        test_id_1 = ObjectId()
        test_id_1_loc = str(test_id_1)
        testobj_1 = CourseLocator(version_guid=test_id_1)
        self.check_course_locn_fields(testobj_1, version_guid=test_id_1)
        self.assertEqual(str(testobj_1.version_guid), test_id_1_loc)
        # Allow access to _to_string
        # pylint: disable=protected-access
        testobj_1_string = u'@'.join((testobj_1.VERSION_PREFIX, test_id_1_loc))
        self.assertEqual(testobj_1._to_string(), testobj_1_string)
        self.assertEqual(str(testobj_1), u'course-v1:' + testobj_1_string)
        self.assertEqual(testobj_1.html_id(), u'course-v1:' + testobj_1_string)
        self.assertEqual(testobj_1.version, test_id_1)

        # Test using a given string
        test_id_2_loc = '519665f6223ebd6980884f2b'
        test_id_2 = ObjectId(test_id_2_loc)
        testobj_2 = CourseLocator(version_guid=test_id_2)
        self.check_course_locn_fields(testobj_2, version_guid=test_id_2)
        self.assertEqual(str(testobj_2.version_guid), test_id_2_loc)
        # Allow access to _to_string
        # pylint: disable=protected-access
        testobj_2_string = u'@'.join((testobj_2.VERSION_PREFIX, test_id_2_loc))
        self.assertEqual(testobj_2._to_string(), testobj_2_string)
        self.assertEqual(str(testobj_2), u'course-v1:' + testobj_2_string)
        self.assertEqual(testobj_2.html_id(), u'course-v1:' + testobj_2_string)
        self.assertEqual(testobj_2.version, test_id_2)
Exemplo n.º 2
0
    def test_course_constructor_version_guid(self):
        # pylint: disable=no-member,protected-access

        # generate a random location
        test_id_1 = ObjectId()
        test_id_1_loc = str(test_id_1)
        testobj_1 = CourseLocator(version_guid=test_id_1)
        self.check_course_locn_fields(testobj_1, version_guid=test_id_1)
        self.assertEqual(str(testobj_1.version_guid), test_id_1_loc)

        testobj_1_string = u'@'.join((testobj_1.VERSION_PREFIX, test_id_1_loc))
        self.assertEqual(testobj_1._to_string(), testobj_1_string)
        self.assertEqual(str(testobj_1), u'course-v1:' + testobj_1_string)
        self.assertEqual(testobj_1.html_id(), u'course-v1:' + testobj_1_string)
        self.assertEqual(testobj_1.version, test_id_1)

        # Test using a given string
        test_id_2_loc = '519665f6223ebd6980884f2b'
        test_id_2 = ObjectId(test_id_2_loc)
        testobj_2 = CourseLocator(version_guid=test_id_2)
        self.check_course_locn_fields(testobj_2, version_guid=test_id_2)
        self.assertEqual(str(testobj_2.version_guid), test_id_2_loc)

        testobj_2_string = u'@'.join((testobj_2.VERSION_PREFIX, test_id_2_loc))
        self.assertEqual(testobj_2._to_string(), testobj_2_string)
        self.assertEqual(str(testobj_2), u'course-v1:' + testobj_2_string)
        self.assertEqual(testobj_2.html_id(), u'course-v1:' + testobj_2_string)
        self.assertEqual(testobj_2.version, test_id_2)
Exemplo n.º 3
0
 def test_course_constructor_package_id_no_branch(self):
     org = 'mit.eecs'
     offering = '6002x'
     testurn = '{}+{}'.format(org, offering)
     testobj = CourseLocator(org=org, offering=offering)
     self.check_course_locn_fields(testobj, org=org, offering=offering)
     self.assertEqual(testobj._to_string(), testurn)
Exemplo n.º 4
0
    def test_course_constructor_version_guid(self):
        # generate a random location
        test_id_1 = ObjectId()
        test_id_1_loc = str(test_id_1)
        testobj_1 = CourseLocator(version_guid=test_id_1)
        self.check_course_locn_fields(testobj_1, version_guid=test_id_1)
        self.assertEqual(str(testobj_1.version_guid), test_id_1_loc)
        self.assertEqual(testobj_1._to_string(), u'+'.join((testobj_1.VERSION_PREFIX, test_id_1_loc)))

        # Test using a given string
        test_id_2_loc = '519665f6223ebd6980884f2b'
        test_id_2 = ObjectId(test_id_2_loc)
        testobj_2 = CourseLocator(version_guid=test_id_2)
        self.check_course_locn_fields(testobj_2, version_guid=test_id_2)
        self.assertEqual(str(testobj_2.version_guid), test_id_2_loc)
        self.assertEqual(testobj_2._to_string(), u'+'.join((testobj_2.VERSION_PREFIX, test_id_2_loc)))
Exemplo n.º 5
0
 def test_course_constructor_package_id_no_branch(self):
     org = 'mit.eecs'
     offering = '6002x'
     testurn = '{}+{}'.format(org, offering)
     testobj = CourseLocator(org=org, offering=offering)
     self.check_course_locn_fields(testobj, org=org, offering=offering)
     self.assertEqual(testobj._to_string(), testurn)
Exemplo n.º 6
0
    def test_course_constructor_version_guid(self):
        # generate a random location
        test_id_1 = ObjectId()
        test_id_1_loc = str(test_id_1)
        testobj_1 = CourseLocator(version_guid=test_id_1)
        self.check_course_locn_fields(testobj_1, version_guid=test_id_1)
        self.assertEqual(str(testobj_1.version_guid), test_id_1_loc)
        self.assertEqual(testobj_1._to_string(), u'+'.join(
            (testobj_1.VERSION_PREFIX, test_id_1_loc)))

        # Test using a given string
        test_id_2_loc = '519665f6223ebd6980884f2b'
        test_id_2 = ObjectId(test_id_2_loc)
        testobj_2 = CourseLocator(version_guid=test_id_2)
        self.check_course_locn_fields(testobj_2, version_guid=test_id_2)
        self.assertEqual(str(testobj_2.version_guid), test_id_2_loc)
        self.assertEqual(testobj_2._to_string(), u'+'.join(
            (testobj_2.VERSION_PREFIX, test_id_2_loc)))
Exemplo n.º 7
0
 def test_course_constructor_package_id_no_branch(self):
     org = 'mit.eecs'
     course = '6002x'
     run = '2014_T2'
     testurn = '{}+{}+{}'.format(org, course, run)
     testobj = CourseLocator(org=org, course=course, run=run)
     self.check_course_locn_fields(testobj, org=org, course=course, run=run)
     # Allow access to _to_string
     # pylint: disable=protected-access
     self.assertEqual(testobj._to_string(), testurn)
 def test_course_constructor_package_id_no_branch(self):
     org = 'mit.eecs'
     course = '6002x'
     run = '2014_T2'
     testurn = '{}+{}+{}'.format(org, course, run)
     testobj = CourseLocator(org=org, course=course, run=run)
     self.check_course_locn_fields(testobj, org=org, course=course, run=run)
     # Allow access to _to_string
     # pylint: disable=protected-access
     self.assertEqual(testobj._to_string(), testurn)
Exemplo n.º 9
0
 def test_course_constructor_package_id_separate_branch(self):
     org = 'mit.eecs'
     offering = '6002x'
     test_branch = 'published'
     expected_urn = '{}+{}+{}+{}'.format(org, offering, CourseLocator.BRANCH_PREFIX, test_branch)
     testobj = CourseLocator(org=org, offering=offering, branch=test_branch)
     self.check_course_locn_fields(
         testobj,
         org=org,
         offering=offering,
         branch=test_branch,
     )
     self.assertEqual(testobj.branch, test_branch)
     self.assertEqual(testobj._to_string(), expected_urn)
Exemplo n.º 10
0
 def test_course_constructor_package_id_separate_branch(self):
     org = 'mit.eecs'
     offering = '6002x'
     test_branch = 'published'
     expected_urn = '{}+{}+{}+{}'.format(org, offering,
                                         CourseLocator.BRANCH_PREFIX,
                                         test_branch)
     testobj = CourseLocator(org=org, offering=offering, branch=test_branch)
     self.check_course_locn_fields(
         testobj,
         org=org,
         offering=offering,
         branch=test_branch,
     )
     self.assertEqual(testobj.branch, test_branch)
     self.assertEqual(testobj._to_string(), expected_urn)
Exemplo n.º 11
0
    def test_course_constructor_package_id_separate_branch(self):
        org = 'mit.eecs'
        course = '6002x'
        run = '2014_T2'
        test_branch = 'published'
        expected_urn = '{}+{}+{}+{}@{}'.format(org, course, run, CourseLocator.BRANCH_PREFIX, test_branch)
        testobj = CourseLocator(org=org, course=course, run=run, branch=test_branch)
        self.check_course_locn_fields(
            testobj,
            org=org,
            course=course,
            run=run,
            branch=test_branch,
        )

        # pylint: disable=no-member,protected-access
        self.assertEqual(testobj.branch, test_branch)
        self.assertEqual(testobj._to_string(), expected_urn)
Exemplo n.º 12
0
    def test_course_constructor_package_id_separate_branch(self):
        org = 'mit.eecs'
        course = '6002x'
        run = '2014_T2'
        test_branch = 'published'
        expected_urn = f'{org}+{course}+{run}+{CourseLocator.BRANCH_PREFIX}@{test_branch}'
        testobj = CourseLocator(org=org,
                                course=course,
                                run=run,
                                branch=test_branch)
        self.check_course_locn_fields(
            testobj,
            org=org,
            course=course,
            run=run,
            branch=test_branch,
        )

        # pylint: disable=no-member,protected-access
        self.assertEqual(testobj.branch, test_branch)
        self.assertEqual(testobj._to_string(), expected_urn)
Exemplo n.º 13
0
 def test_course_constructor_package_id_separate_branch(self):
     org = 'mit.eecs'
     course = '6002x'
     run = '2014_T2'
     test_branch = 'published'
     expected_urn = '{}+{}+{}+{}@{}'.format(org, course, run,
                                            CourseLocator.BRANCH_PREFIX,
                                            test_branch)
     testobj = CourseLocator(org=org,
                             course=course,
                             run=run,
                             branch=test_branch)
     self.check_course_locn_fields(
         testobj,
         org=org,
         course=course,
         run=run,
         branch=test_branch,
     )
     self.assertEqual(testobj.branch, test_branch)
     # Allow access to _to_string
     # pylint: disable=protected-access
     self.assertEqual(testobj._to_string(), expected_urn)