Exemplo n.º 1
0
    def test_has_changes(self):
        """
        Tests that has_changes() only returns true when changes are present
        """
        draft_course = CourseLocator(
            org='testx', course='GreekHero', run='run', branch=ModuleStoreEnum.BranchName.draft
        )
        head = draft_course.make_usage_key('course', 'head12345')
        dummy_user = ModuleStoreEnum.UserID.test

        # Not yet published, so changes are present
        self.assertTrue(self.module_store.has_changes(head))

        # Publish and verify that there are no unpublished changes
        self.module_store.publish(head, dummy_user)
        self.assertFalse(self.module_store.has_changes(head))

        # Change the course, then check that there now are changes
        course = self.module_store.get_item(head)
        course.show_calculator = not course.show_calculator
        self.module_store.update_item(course, dummy_user)
        self.assertTrue(self.module_store.has_changes(head))

        # Publish and verify again
        self.module_store.publish(head, dummy_user)
        self.assertFalse(self.module_store.has_changes(head))
class SetupTestErrorModules(unittest.TestCase):
    """Common setUp for use in ErrorModule tests."""
    def setUp(self):
        super(SetupTestErrorModules, self).setUp()
        self.system = get_test_system()
        self.course_id = CourseLocator('org', 'course', 'run')
        self.location = self.course_id.make_usage_key('foo', 'bar')
        self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
        self.error_msg = "Error"
class SetupTestErrorModules(unittest.TestCase):
    """Common setUp for use in ErrorModule tests."""
    def setUp(self):
        super(SetupTestErrorModules, self).setUp()
        self.system = get_test_system()
        self.course_id = CourseLocator('org', 'course', 'run')
        self.location = self.course_id.make_usage_key('foo', 'bar')
        self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
        self.error_msg = "Error"
Exemplo n.º 4
0
    def lms_link_test(self):
        """ Tests get_lms_link_for_item. """
        course_key = CourseLocator('mitX', '101', 'test')
        location = course_key.make_usage_key('vertical', 'contacting_us')
        link = utils.get_lms_link_for_item(location, False)
        self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block@contacting_us")

        # test preview
        link = utils.get_lms_link_for_item(location, True)
        self.assertEquals(
            link,
            "//preview.localhost/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block@contacting_us"
        )

        # now test with the course' location
        location = course_key.make_usage_key('course', 'test')
        link = utils.get_lms_link_for_item(location)
        self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@course+block@test")
 def initialize_ids(self):
     """Define set of id values for use in tests."""
     course_key = CourseLocator(org='FooX', course='1.23x', run='2013_Spring')
     self.course_id = unicode(course_key)
     self.org_id = course_key.org
     block_id = "9cee77a606ea4c1aa5440e0ea5d0f618"
     self.problem_id = unicode(course_key.make_usage_key("problem", block_id))
     self.answer_id = "{block_id}_2_1".format(block_id=block_id)
     self.second_answer_id = "{block_id}_3_1".format(block_id=block_id)
Exemplo n.º 6
0
def instantiate_descriptor(**field_data):
    """
    Instantiate descriptor with most properties.
    """
    system = get_test_descriptor_system()
    course_key = CourseLocator('org', 'course', 'run')
    usage_key = course_key.make_usage_key('video', 'SampleProblem')
    return system.construct_xblock_from_class(
        VideoDescriptor,
        scope_ids=ScopeIds(None, None, usage_key, usage_key),
        field_data=DictFieldData(field_data),
    )
 def initialize_ids(self):
     """Define set of id values for use in tests."""
     course_key = CourseLocator(org='FooX',
                                course='1.23x',
                                run='2013_Spring')
     self.course_id = unicode(course_key)
     self.org_id = course_key.org
     block_id = "9cee77a606ea4c1aa5440e0ea5d0f618"
     self.problem_id = unicode(
         course_key.make_usage_key("problem", block_id))
     self.answer_id = "{block_id}_2_1".format(block_id=block_id)
     self.second_answer_id = "{block_id}_3_1".format(block_id=block_id)
Exemplo n.º 8
0
def instantiate_descriptor(**field_data):
    """
    Instantiate descriptor with most properties.
    """
    system = get_test_descriptor_system()
    course_key = CourseLocator('org', 'course', 'run')
    usage_key = course_key.make_usage_key('video', 'SampleProblem')
    return system.construct_xblock_from_class(
        VideoDescriptor,
        scope_ids=ScopeIds(None, None, usage_key, usage_key),
        field_data=DictFieldData(field_data),
    )
    def lms_link_test(self):
        """ Tests get_lms_link_for_item. """
        course_key = CourseLocator('mitX', '101', 'test')
        location = course_key.make_usage_key('vertical', 'contacting_us')
        link = utils.get_lms_link_for_item(location, False)
        self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type"
                               "@vertical+block@contacting_us")

        # test preview
        link = utils.get_lms_link_for_item(location, True)
        self.assertEqual(
            link,
            "//preview.localhost/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block"
            "@contacting_us "
        )

        # now test with the course' location
        location = course_key.make_usage_key('course', 'test')
        link = utils.get_lms_link_for_item(location)
        self.assertEqual(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type"
                               "@course+block@test")