Esempio n. 1
0
    def test_no_attribute_mapping(self):
        # Policy files are json, and thus the values aren't passed through 'deserialize_field'
        # Therefor, the string 'null' is passed unchanged to the Float field, which will trigger
        # a ValueError
        with assert_raises(ValueError):
            course = self.process_xml(CourseFactory.build(policy={'days_early_for_beta': 'null'}))

            # Trigger the exception by looking at the imported data
            course.days_early_for_beta  # pylint: disable=pointless-statement
Esempio n. 2
0
 def test_video_attr(self):
     """
     Test that video's definition_from_xml handles unknown attrs w/o choking
     """
     # Fixes LMS-11491
     root = CourseFactory.build()
     sequence = SequenceFactory.build(parent=root)
     video = XmlImportFactory(
         parent=sequence, tag="video", attribs={"parent_url": "foo", "garbage": "asdlk", "download_video": "true"}
     )
     video_block = self.process_xml(video)
     assert_in("garbage", video_block.xml_attributes)
Esempio n. 3
0
    def test_null_string(self):
        # Test that the string inherited fields are passed through 'deserialize_field',
        # which converts the string "null" to the python value None
        root = CourseFactory.build(days_early_for_beta="null")
        sequence = SequenceFactory.build(parent=root)
        ProblemFactory.build(parent=sequence)

        course = self.process_xml(root)
        assert_equals(None, course.days_early_for_beta)

        sequence = course.get_children()[0]
        assert_equals(None, sequence.days_early_for_beta)

        problem = sequence.get_children()[0]
        assert_equals(None, problem.days_early_for_beta)
 def test_video_attr(self):
     """
     Test that video's definition_from_xml handles unknown attrs w/o choking
     """
     # Fixes LMS-11491
     root = CourseFactory.build()
     sequence = SequenceFactory.build(parent=root)
     video = XmlImportFactory(
         parent=sequence,
         tag='video',
         attribs={
             'parent_url': 'foo', 'garbage': 'asdlk',
             'download_video': 'true',
         }
     )
     video_block = self.process_xml(video)
     assert 'garbage' in video_block.xml_attributes
Esempio n. 5
0
    def test_course_policy(self):
        course = self.process_xml(CourseFactory.build(policy={'days_early_for_beta': None}))
        assert_equals(None, course.days_early_for_beta)

        course = self.process_xml(CourseFactory.build(policy={'days_early_for_beta': 9}))
        assert_equals(9, course.days_early_for_beta)
 def test_known_attribute(self):
     assert_true(hasattr(CourseDescriptor, 'show_calculator'))
     course = self.process_xml(CourseFactory.build(show_calculator='true'))
     assert_true(course.show_calculator)
     assert_not_in('show_calculator', course.xml_attributes)
 def test_unknown_attribute(self):
     assert_false(hasattr(CourseDescriptor, 'unknown_attr'))
     course = self.process_xml(CourseFactory.build(unknown_attr='value'))
     assert_false(hasattr(course, 'unknown_attr'))
     assert_equals('value', course.xml_attributes['unknown_attr'])
Esempio n. 8
0
 def test_unknown_attribute(self):
     assert not hasattr(CourseBlock, 'unknown_attr')
     course = self.process_xml(CourseFactory.build(unknown_attr='value'))
     assert not hasattr(course, 'unknown_attr')
     assert course.xml_attributes['unknown_attr'] == 'value'
 def test_known_attribute(self):
     assert_true(hasattr(CourseDescriptor, 'show_calculator'))
     course = self.process_xml(CourseFactory.build(show_calculator='true'))
     assert_true(course.show_calculator)
     assert_not_in('show_calculator', course.xml_attributes)
Esempio n. 10
0
 def test_unknown_attribute(self):
     assert_false(hasattr(CourseDescriptor, 'unknown_attr'))
     course = self.process_xml(CourseFactory.build(unknown_attr='value'))
     assert_false(hasattr(course, 'unknown_attr'))
     assert_equals('value', course.xml_attributes['unknown_attr'])
Esempio n. 11
0
    def test_course_policy(self):
        course = self.process_xml(CourseFactory.build(policy={'days_early_for_beta': None}))
        assert course.days_early_for_beta is None

        course = self.process_xml(CourseFactory.build(policy={'days_early_for_beta': 9}))
        assert course.days_early_for_beta == 9
 def test_known_attribute(self):
     assert hasattr(CourseBlock, 'show_calculator')
     course = self.process_xml(CourseFactory.build(show_calculator='true'))
     assert course.show_calculator
     assert 'show_calculator' not in course.xml_attributes
 def test_known_attribute(self):
     assert hasattr(CourseDescriptor, 'show_calculator')
     course = self.process_xml(CourseFactory.build(show_calculator='true'))
     assert course.show_calculator
     assert 'show_calculator' not in course.xml_attributes
 def test_unknown_attribute(self):
     assert not hasattr(CourseDescriptor, 'unknown_attr')
     course = self.process_xml(CourseFactory.build(unknown_attr='value'))
     assert not hasattr(course, 'unknown_attr')
     assert course.xml_attributes['unknown_attr'] == 'value'