本文整理汇总了Python中xmodule.tests.xml.factories.CourseFactory类的典型用法代码示例。如果您正苦于以下问题:Python CourseFactory类的具体用法?Python CourseFactory怎么用?Python CourseFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CourseFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_attribute_mapping
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
示例2: test_video_attr
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)
示例3: test_null_string
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)
示例4: test_video_attr
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
示例5: test_course_policy
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)
示例6: test_known_attribute
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)
示例7: test_unknown_attribute
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'])
示例8: test_course_policy
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
示例9: test_known_attribute
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
示例10: test_unknown_attribute
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'