示例#1
0
    def test_validate(self):
        page = PageFactory.create(url='http://globo.com/')

        reviewer = Reviewer(
            api_url='http://localhost:2368',
            page_uuid=page.uuid,
            page_url=page.url,
            page_score=0.0,
            config=Config(),
            validators=[]
        )

        validator = RobotsValidator(reviewer)

        response = Mock(status_code=200, text='key:value')

        validator.review.data['robots.response'] = response
        validator.add_violation = Mock()

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='robots.sitemap.not_found',
                value=None,
                points=100
            ))

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='robots.disallow.not_found',
                value=None,
                points=100
            ))
示例#2
0
    def test_validate_if_page_is_not_root_of_domain(self):
        page = PageFactory.create(url='http://globo.com/1')

        reviewer = Reviewer(
            api_url='http://localhost:2368',
            page_uuid=page.uuid,
            page_url=page.url,
            page_score=0.0,
            config=Config(),
            validators=[]
        )

        validator = RobotsValidator(reviewer)
        validator.review.data['robots.response'] = Mock(status_code=404, text=None)
        validator.add_violation = Mock()

        validator.validate()

        expect(validator.add_violation.call_count).to_equal(0)
示例#3
0
    def test_add_violation_when_empty(self):
        page = PageFactory.create(url='http://globo.com/')

        reviewer = Reviewer(
            api_url='http://localhost:2368',
            page_uuid=page.uuid,
            page_url=page.url,
            page_score=0.0,
            config=Config(),
            validators=[]
        )

        validator = RobotsValidator(reviewer)
        response = Mock(status_code=200, text='')
        validator.review.data['robots.response'] = response
        validator.add_violation = Mock()

        validator.validate()

        validator.add_violation.assert_called_once_with(
            key='robots.empty',
            value=response.url,
            points=100
        )