本文整理汇总了Python中xmodule.tests.xml.factories.ProblemFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python ProblemFactory.build方法的具体用法?Python ProblemFactory.build怎么用?Python ProblemFactory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmodule.tests.xml.factories.ProblemFactory
的用法示例。
在下文中一共展示了ProblemFactory.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_inheritable_attribute
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
def check_inheritable_attribute(self, attribute, value):
# `attribute` isn't a basic attribute of Sequence
assert_false(hasattr(SequenceDescriptor, attribute))
# `attribute` is added by InheritanceMixin
assert_true(hasattr(InheritanceMixin, attribute))
root = SequenceFactory.build(policy={attribute: str(value)})
ProblemFactory.build(parent=root)
# InheritanceMixin will be used when processing the XML
assert_in(InheritanceMixin, root.xblock_mixins)
seq = self.process_xml(root)
assert_equals(seq.unmixed_class, SequenceDescriptor)
assert_not_equals(type(seq), SequenceDescriptor)
# `attribute` is added to the constructed sequence, because
# it's in the InheritanceMixin
assert_equals(value, getattr(seq, attribute))
# `attribute` is a known attribute, so we shouldn't include it
# in xml_attributes
assert_not_in(attribute, seq.xml_attributes)
示例2: test_inheritable_attribute
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
def test_inheritable_attribute(self):
# days_early_for_beta isn't a basic attribute of Sequence
assert_false(hasattr(SequenceDescriptor, 'days_early_for_beta'))
# days_early_for_beta is added by InheritanceMixin
assert_true(hasattr(InheritanceMixin, 'days_early_for_beta'))
root = SequenceFactory.build(policy={'days_early_for_beta': '2'})
ProblemFactory.build(parent=root)
# InheritanceMixin will be used when processing the XML
assert_in(InheritanceMixin, root.xblock_mixins)
seq = self.process_xml(root)
assert_equals(seq.unmixed_class, SequenceDescriptor)
assert_not_equals(type(seq), SequenceDescriptor)
# days_early_for_beta is added to the constructed sequence, because
# it's in the InheritanceMixin
assert_equals(2, seq.days_early_for_beta)
# days_early_for_beta is a known attribute, so we shouldn't include it
# in xml_attributes
assert_not_in('days_early_for_beta', seq.xml_attributes)
示例3: check_inheritable_attribute
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
def check_inheritable_attribute(self, attribute, value):
# `attribute` isn't a basic attribute of Sequence
assert not hasattr(SequenceDescriptor, attribute)
# `attribute` is added by InheritanceMixin
assert hasattr(InheritanceMixin, attribute)
root = SequenceFactory.build(policy={attribute: str(value)})
ProblemFactory.build(parent=root)
# InheritanceMixin will be used when processing the XML
assert InheritanceMixin in root.xblock_mixins
seq = self.process_xml(root)
assert seq.unmixed_class == SequenceDescriptor
assert type(seq) != SequenceDescriptor
# `attribute` is added to the constructed sequence, because
# it's in the InheritanceMixin
assert getattr(seq, attribute) == value
# `attribute` is a known attribute, so we shouldn't include it
# in xml_attributes
assert attribute not in seq.xml_attributes
示例4: test_rerandomize_in_policy
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
def test_rerandomize_in_policy(self):
# Rerandomize isn't a basic attribute of Sequence
assert_false(hasattr(SequenceDescriptor, 'rerandomize'))
root = SequenceFactory.build(policy={'rerandomize': 'never'})
ProblemFactory.build(parent=root)
seq = self.process_xml(root)
# Rerandomize is added to the constructed sequence via the InheritanceMixin
assert_equals('never', seq.rerandomize)
# Rerandomize is a known value coming from policy, and shouldn't appear
# in xml_attributes
assert_not_in('rerandomize', seq.xml_attributes)
示例5: test_null_string
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
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)
示例6: test_attempts_in_policy
# 需要导入模块: from xmodule.tests.xml.factories import ProblemFactory [as 别名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 别名]
def test_attempts_in_policy(self):
# attempts isn't a basic attribute of Sequence
assert_false(hasattr(SequenceDescriptor, 'attempts'))
root = SequenceFactory.build(policy={'attempts': '1'})
ProblemFactory.build(parent=root)
seq = self.process_xml(root)
# attempts isn't added to the constructed sequence, because
# it's not in the InheritanceMixin
assert_false(hasattr(seq, 'attempts'))
# attempts is an unknown attribute, so we should include it
# in xml_attributes so that it gets written out (despite the misleading
# name)
assert_in('attempts', seq.xml_attributes)