本文整理汇总了Python中tests.fixtures.PageFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python PageFactory.build方法的具体用法?Python PageFactory.build怎么用?Python PageFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.fixtures.PageFactory
的用法示例。
在下文中一共展示了PageFactory.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_dict
# 需要导入模块: from tests.fixtures import PageFactory [as 别名]
# 或者: from tests.fixtures.PageFactory 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_to_dict
# 需要导入模块: from tests.fixtures import PageFactory [as 别名]
# 或者: from tests.fixtures.PageFactory 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,
}
)