コード例 #1
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)))
コード例 #2
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)
コード例 #3
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)