Beispiel #1
0
    def test_can_get_violation_definitions(self):
        reviewer = Mock()
        validator = BodyValidator(reviewer)

        definitions = validator.get_violation_definitions()

        expect(definitions).to_length(1)
        expect('page.body.not_found' in definitions).to_be_true()
Beispiel #2
0
    def test_validate(self):
        config = Config()

        page = PageFactory.create()

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

        content = '<html></html>'

        result = {
            'url': page.url,
            'status': 200,
            'content': content,
            'html': lxml.html.fromstring(content)
        }
        reviewer.responses[page.url] = result
        reviewer.get_response = Mock(return_value=result)

        validator = BodyValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.body': []
        }

        validator.validate()

        validator.add_violation.assert_called_once_with(
            key='page.body.not_found',
            value=page.url,
            points=50
        )