def test_no_body_tag(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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()

        validator.validate()

        expect(validator.add_violation.called).to_be_false()
Ejemplo n.º 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><body></body></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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {'page.body': [{}]}

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(key='absent.schema.itemscope', value=None, points=10))

        expect(validator.add_violation.call_args_list).to_include(
            call(key='absent.schema.itemtype', value=None, points=10))
Ejemplo n.º 3
0
    def test_no_body_tag(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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()

        validator.validate()

        expect(validator.add_violation.called).to_be_false()
    def test_has_invalid_itemtype(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=[],
            cache=self.sync_cache
        )

        reviewer.violation_definitions = {
            'invalid.schema.itemtype': {
                'default_value': ['http://schema.org/AboutPage']
            }
        }

        content = '<html><body itemtype="http://schema.org/a"></body></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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.body': [{'itemtype': 'a'}]
        }

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='invalid.schema.itemtype',
                value=None,
                points=10
            ))
    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><body></body></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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.body': [{}]
        }

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='absent.schema.itemscope',
                value=None,
                points=10
            ))

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='absent.schema.itemtype',
                value=None,
                points=10
            ))
Ejemplo n.º 6
0
    def test_has_invalid_itemtype(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=[],
                            cache=self.sync_cache)

        reviewer.violation_definitions = {
            'invalid.schema.itemtype': {
                'default_value': ['http://schema.org/AboutPage']
            }
        }

        content = '<html><body itemtype="http://schema.org/a"></body></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 = SchemaOrgItemTypeValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {'page.body': [{'itemtype': 'a'}]}

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(key='invalid.schema.itemtype', value=None, points=10))