本文整理汇总了Python中models.courses.Workflow.validate方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.validate方法的具体用法?Python Workflow.validate怎么用?Python Workflow.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.courses.Workflow
的用法示例。
在下文中一共展示了Workflow.validate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_not_dict
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_not_dict(self):
"""Validation should fail for non-dict YAML strings."""
yaml_strs = ['- first\n- second', 'grader']
for yaml_str in yaml_strs:
self.errors = []
workflow = Workflow(yaml_str)
workflow.validate(self.errors)
self.assert_matching_errors(
['expected the YAML representation of a dict'], self.errors)
示例2: test_submission_date_after_review_date_fails
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_submission_date_after_review_date_fails(self):
"""Validation should fail if review date precedes submission date."""
workflow_dict = self.valid_human_review_workflow_dict
workflow_dict['submission_due_date'] = '2013-03-14 12:00'
workflow_dict['review_due_date'] = '2013-03-13 12:00'
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors(
['submission due date should be earlier than review due date.'],
self.errors)
示例3: test_multiple_errors
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_multiple_errors(self):
"""Validation should fail with multiple errors when appropriate."""
workflow_dict = self.valid_human_review_workflow_dict
workflow_dict['submission_due_date'] = '2013-03-14 12:00'
workflow_dict['review_due_date'] = '2013-03-13 12:00'
workflow_dict['review_window_mins'] = 'hello'
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors(
['review_window_mins should be an integer; submission due date '
'should be earlier than review due date.'],
self.errors)
示例4: test_invalid_date
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_invalid_date(self):
"""Validation should fail for invalid dates."""
workflow_dict = self.valid_human_review_workflow_dict
workflow_dict['submission_due_date'] = 'test_string'
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors([DATE_FORMAT_ERROR], self.errors)
self.errors = []
workflow_dict = self.valid_human_review_workflow_dict
workflow_dict['review_due_date'] = 'test_string'
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors([DATE_FORMAT_ERROR], self.errors)
示例5: test_invalid_human_grader
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_invalid_human_grader(self):
"""Validation should fail for invalid human grading specifications."""
workflow = Workflow(self.to_yaml({'grader': 'human'}))
workflow.validate(self.errors)
self.assert_matching_errors([
'%s matcher, review_min_count, review_window_mins, '
'submission_due_date, review_due_date.' %
MISSING_KEYS_PREFIX], self.errors)
self.errors = []
workflow = Workflow(self.to_yaml(
{'grader': 'human', 'matcher': 'peer'}
))
workflow.validate(self.errors)
self.assert_matching_errors([
'%s review_min_count, review_window_mins, submission_due_date, '
'review_due_date.' % MISSING_KEYS_PREFIX], self.errors)
示例6: test_invalid_review_min_count
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_invalid_review_min_count(self):
"""Validation should fail for bad review_min_count values."""
workflow_dict = self.valid_human_review_workflow_dict
workflow_dict['review_min_count'] = 'test_string'
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors(
['review_min_count should be an integer.'], self.errors)
self.errors = []
workflow_dict['review_min_count'] = -1
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assert_matching_errors(
['review_min_count should be a non-negative integer.'], self.errors)
self.errors = []
workflow_dict['review_min_count'] = 0
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assertFalse(self.errors)
示例7: test_invalid_string
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_invalid_string(self):
"""Validation should fail for invalid YAML strings."""
workflow = Workflow('(')
workflow.validate(self.errors)
self.assertTrue(self.errors)
示例8: test_empty_string
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_empty_string(self):
"""Validation should fail on an empty string."""
workflow = Workflow('')
workflow.validate(self.errors)
self.assert_matching_errors(['missing key: grader.'], self.errors)
示例9: test_valid_human_grader
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_valid_human_grader(self):
"""Validation should pass for valid human grading specifications."""
workflow_dict = self.valid_human_review_workflow_dict
workflow = Workflow(self.to_yaml(workflow_dict))
workflow.validate(self.errors)
self.assertFalse(self.errors)
示例10: test_empty_submission_date_in_grader
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_empty_submission_date_in_grader(self):
"""Validation should pass for empty submission date."""
workflow = Workflow(self.to_yaml(
{'grader': 'auto', 'submission_due_date': ''}))
workflow.validate(self.errors)
self.assertFalse(self.errors)
示例11: test_auto_grader
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_auto_grader(self):
"""Validation should pass for an auto-graded assessment."""
workflow = Workflow(self.to_yaml({'grader': 'auto'}))
workflow.validate(self.errors)
self.assertFalse(self.errors)
示例12: test_missing_grader_key
# 需要导入模块: from models.courses import Workflow [as 别名]
# 或者: from models.courses.Workflow import validate [as 别名]
def test_missing_grader_key(self):
"""Validation should fail for missing grader key."""
workflow = Workflow(self.to_yaml({'not_grader': 'human'}))
workflow.validate(self.errors)
self.assert_matching_errors(['missing key: grader.'], self.errors)