本文整理汇总了Python中tests.fixtures.ReviewFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewFactory.build方法的具体用法?Python ReviewFactory.build怎么用?Python ReviewFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.fixtures.ReviewFactory
的用法示例。
在下文中一共展示了ReviewFactory.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_dict
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_to_dict(self):
page_id = uuid4()
review_id = uuid4()
page = PageFactory.build(uuid=page_id)
review = ReviewFactory.build(page=page, uuid=review_id)
key1 = KeyFactory.create(name='some.random.key1')
review.add_violation(key1, 'b', 100, review.domain)
key2 = KeyFactory.create(name='some.random.key2')
review.add_fact(key2, 'b')
fact_definitions = {'some.random.key2': {}}
violation_definitions = {'some.random.key1': {}}
expect(review.to_dict(fact_definitions, violation_definitions)).to_be_like({
'domain': review.domain.name,
'uuid': str(review_id),
'completedAt': None,
'facts': [
{'value': 'b', 'key': 'some.random.key2', 'unit': 'value', 'title': 'unknown', 'category': 'unknown'}
],
'violations': [
{'points': 100, 'key': 'some.random.key1', 'description': 'b', 'title': 'undefined', 'category': 'undefined'}
],
'page': {
'url': page.url,
'lastModified': None,
'expires': None,
'uuid': str(page_id),
'score': 0.0
},
'createdAt': review.created_date,
'isComplete': False
})
示例2: test_can_append_facts
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_can_append_facts(self):
review = ReviewFactory.build()
expect(review.facts).to_length(0)
key = KeyFactory.create(name='a')
review.add_fact(key, 'b')
expect(review.facts).to_length(1)
expect(review.facts[0].key.name).to_equal('a')
expect(review.facts[0].value).to_equal('b')
示例3: test_can_append_violations
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_can_append_violations(self):
review = ReviewFactory.build()
expect(review.violations).to_length(0)
key = KeyFactory.create(name='a')
review.add_violation(key, 'b', 100, review.domain)
expect(review.violations).to_length(1)
expect(review.violations[0].key.name).to_equal('a')
expect(review.violations[0].value).to_equal('b')
expect(review.violations[0].points).to_equal(100)
示例4: test_cant_append_violations_after_complete
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_cant_append_violations_after_complete(self):
review = ReviewFactory.build()
expect(review.facts).to_length(0)
review.is_complete = True
try:
key = KeyFactory.create(name='a')
review.add_violation(key, 'b', 10, review.domain)
except ValueError:
err = sys.exc_info()[1]
expect(err).to_have_an_error_message_of("Can't add anything to a completed review.")
else:
assert False, 'Should not have gotten this far'
示例5: test_to_dict
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_to_dict(self):
page_id = uuid4()
review_id = uuid4()
page = PageFactory.build(uuid=page_id)
review = ReviewFactory.build(page=page, uuid=review_id)
key1 = KeyFactory.create(name="some.random.key1")
review.add_violation(key1, "b", 100, review.domain)
key2 = KeyFactory.create(name="some.random.key2")
review.add_fact(key2, "b")
fact_definitions = {"some.random.key2": {}}
violation_definitions = {"some.random.key1": {}}
expect(review.to_dict(fact_definitions, violation_definitions, _)).to_be_like(
{
"domain": review.domain.name,
"uuid": str(review_id),
"completedAt": None,
"facts": [
{
"value": "b",
"key": "some.random.key2",
"unit": "value",
"title": "unknown",
"category": "unknown",
}
],
"violations": [
{
"points": 100,
"key": "some.random.key1",
"description": "b",
"title": "undefined",
"category": "undefined",
}
],
"page": {"url": page.url, "lastModified": None, "expires": None, "uuid": str(page_id), "score": 0.0},
"createdAt": review.created_date,
"isComplete": False,
}
)
示例6: test_review_has_failed
# 需要导入模块: from tests.fixtures import ReviewFactory [as 别名]
# 或者: from tests.fixtures.ReviewFactory import build [as 别名]
def test_review_has_failed(self):
review = ReviewFactory.build()
review.failure_message = "Invalid Page"
expect(review.failed).to_be_true()