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


Python Page.by_uuid方法代码示例

本文整理汇总了Python中holmes.models.Page.by_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python Page.by_uuid方法的具体用法?Python Page.by_uuid怎么用?Python Page.by_uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在holmes.models.Page的用法示例。


在下文中一共展示了Page.by_uuid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_can_get_page_by_uuid

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def test_can_get_page_by_uuid(self):
        page = PageFactory.create()
        PageFactory.create()

        loaded_page = Page.by_uuid(page.uuid, self.db)
        expect(loaded_page.id).to_equal(page.id)

        invalid_page = Page.by_uuid(uuid4(), self.db)
        expect(invalid_page).to_be_null()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:11,代码来源:test_page.py

示例2: get

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def get(self, uuid="", limit=10):
        uuid = UUID(uuid)

        page = Page.by_uuid(uuid, self.db)

        if not page:
            self.set_status(404, self._("Page UUID [%s] not found") % uuid)
            return

        reviews = (
            self.db.query(Review)
            .filter(Review.page == page)
            .filter(Review.is_complete == True)
            .order_by(Review.completed_date.desc())[:limit]
        )

        result = []
        for review in reviews:
            result.append(
                {
                    "uuid": str(review.uuid),
                    "completedAt": review.completed_date,
                    "violationCount": review.violation_count,
                }
            )

        self.write_json(result)
开发者ID:skyonamine,项目名称:holmes-api,代码行数:29,代码来源:page.py

示例3: get

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def get(self, page_uuid, review_uuid):
        review = None
        page = None
        if self._parse_uuid(review_uuid):
            review = Review.by_uuid(review_uuid, self.db)

        if self._parse_uuid(page_uuid):
            page = Page.by_uuid(page_uuid, self.db)

        if not review and page:
            self.redirect('/page/%s/review/%s/' % (page_uuid, page.last_review_uuid))
            return

        if not page:
            self.set_status(404, self._('Page UUID [%s] not found') % page_uuid)
            return

        result = review.to_dict(self.application.fact_definitions,
                                self.application.violation_definitions,
                                self._)
        result.update({
            'violationPoints': review.get_violation_points(),
            'violationCount': review.violation_count,
        })

        self.write_json(result)
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:28,代码来源:review.py

示例4: test_can_save

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def test_can_save(self):
        self.mock_request(status_code=200, effective_url="http://www.globo.com")

        self.server.application.girl = Mock()

        response = yield self.authenticated_fetch(
            '/page', method='POST', body=dumps({
                'url': 'http://www.globo.com'
            })
        )

        expect(response.code).to_equal(200)

        page_uuid = UUID(response.body)
        page = Page.by_uuid(page_uuid, self.db)

        expect(page).not_to_be_null()
        expect(str(page_uuid)).to_equal(page.uuid)

        expect(self.server.application.girl.expire.call_count).to_equal(4)
        self.server.application.girl.assert_has_calls([
            call.expire('domains_details'),
            call.expire('failed_responses_count'),
            call.expire('violation_count_for_domains'),
            call.expire('top_violations_in_category_for_domains'),
        ])
开发者ID:diegosaouda,项目名称:holmes-api,代码行数:28,代码来源:test_page.py

示例5: test_can_get_page_by_url_hash

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def test_can_get_page_by_url_hash(self):
        page = PageFactory.create()
        PageFactory.create()

        loaded_page = Page.by_url_hash(page.url_hash, self.db)
        expect(loaded_page.id).to_equal(page.id)

        invalid_page = Page.by_uuid('123', self.db)
        expect(invalid_page).to_be_null()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:11,代码来源:test_page.py

示例6: test_can_save_known_domain

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def test_can_save_known_domain(self):
        DomainFactory.create(url='http://www.globo.com', name='globo.com')

        self.mock_request(status_code=200, effective_url="http://www.globo.com")

        response = self.fetch(
            '/page',
            method='POST',
            body=dumps({
                'url': 'http://www.globo.com'
            })
        )

        expect(response.code).to_equal(200)

        page_uuid = UUID(response.body)
        page = Page.by_uuid(page_uuid, self.db)

        expect(page).not_to_be_null()
        expect(str(page_uuid)).to_equal(page.uuid)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:22,代码来源:test_page.py

示例7: test_can_save

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def test_can_save(self):
        def side_effect(*args, **kw):
            response_mock = Mock(status_code=200, effective_url="http://www.globo.com")
            kw['callback'](response_mock)

        self.mock_request(status_code=200, effective_url="http://www.globo.com")

        response = yield self.http_client.fetch(
            self.get_url('/page'),
            method='POST',
            body=dumps({
                'url': 'http://www.globo.com'
            })
        )

        expect(response.code).to_equal(200)

        page_uuid = UUID(response.body)
        page = Page.by_uuid(page_uuid, self.db)

        expect(page).not_to_be_null()
        expect(str(page_uuid)).to_equal(page.uuid)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:24,代码来源:test_page.py

示例8: get

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import by_uuid [as 别名]
    def get(self, uuid='', limit=10):
        uuid = UUID(uuid)

        page = Page.by_uuid(uuid, self.db)

        if not page:
            self.set_status(404, 'Page UUID [%s] not found' % uuid)
            return

        reviews = self.db.query(Review) \
            .filter(Review.page == page) \
            .filter(Review.is_complete == True) \
            .order_by(Review.completed_date.desc())[:limit]

        result = []
        for review in reviews:
            result.append({
                'uuid': str(review.uuid),
                'completedAt': review.completed_date,
                'violationCount': review.violation_count
            })

        self.write_json(result)
开发者ID:pombredanne,项目名称:holmes-api,代码行数:25,代码来源:page.py


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