当前位置: 首页>>代码示例>>Python>>正文


Python ReviewFactory.build方法代码示例

本文整理汇总了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
        })
开发者ID:pombredanne,项目名称:holmes-api,代码行数:35,代码来源:test_review.py

示例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')
开发者ID:pombredanne,项目名称:holmes-api,代码行数:12,代码来源:test_review.py

示例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)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:13,代码来源:test_review.py

示例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'
开发者ID:pombredanne,项目名称:holmes-api,代码行数:15,代码来源:test_review.py

示例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,
            }
        )
开发者ID:skyonamine,项目名称:holmes-api,代码行数:43,代码来源:test_review.py

示例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()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:6,代码来源:test_review.py


注:本文中的tests.fixtures.ReviewFactory.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。