def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_JS_KB_PER_PAGE_AFTER_GZIP = 70
        config.MAX_JS_REQUESTS_PER_PAGE = 5

        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=[]
        )

        validator = JSRequestsValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('total.size.js')
        expect(violations_values).to_include('total.requests.js')

        expect(violations_values['total.size.js']).to_length(2)
        expect(violations_values['total.requests.js']).to_length(2)

        expect(violations_values['total.size.js']).to_be_like({
            'value': config.MAX_JS_KB_PER_PAGE_AFTER_GZIP,
            'description': config.get_description('MAX_JS_KB_PER_PAGE_AFTER_GZIP')
        })

        expect(violations_values['total.requests.js']).to_be_like({
            'value': config.MAX_JS_REQUESTS_PER_PAGE,
            'description': config.get_description('MAX_JS_REQUESTS_PER_PAGE')
        })
    def test_can_get_default_violations_values(self):
        config = Config()
        config.REQUIRED_META_TAGS = ['description']

        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=[]
        )

        validator = RequiredMetaTagsValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('absent.meta.tags')

        expect(violations_values['absent.meta.tags']).to_length(2)

        expect(violations_values['absent.meta.tags']).to_be_like({
            'value': config.REQUIRED_META_TAGS,
            'description': config.get_description('REQUIRED_META_TAGS')
        })
    def test_can_get_default_violations_values(self):
        config = Config()
        config.SCHEMA_ORG_ITEMTYPE = [
            'http://schema.org/WebPage',
            'http://schema.org/AboutPage',
        ]

        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=[]
        )

        validator = SchemaOrgItemTypeValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('invalid.schema.itemtype')

        expect(violations_values['invalid.schema.itemtype']).to_length(2)

        expect(violations_values['invalid.schema.itemtype']).to_equal({
            'value': config.SCHEMA_ORG_ITEMTYPE,
            'description': config.get_description('SCHEMA_ORG_ITEMTYPE')
        })
    def test_can_get_default_violations_values(self):
        config = Config()
        config.REQUIRED_META_TAGS = ['description']

        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=[])

        validator = RequiredMetaTagsValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('absent.meta.tags')

        expect(violations_values['absent.meta.tags']).to_length(2)

        expect(violations_values['absent.meta.tags']).to_be_like({
            'value':
            config.REQUIRED_META_TAGS,
            'description':
            config.get_description('REQUIRED_META_TAGS')
        })
Example #5
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.FORCE_CANONICAL = False

        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=[])

        validator = LinkWithRelCanonicalValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('absent.meta.canonical')

        expect(violations_values['absent.meta.canonical']).to_length(2)

        expect(violations_values['absent.meta.canonical']).to_be_like({
            'value':
            config.FORCE_CANONICAL,
            'description':
            config.get_description('FORCE_CANONICAL')
        })
Example #6
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.BLACKLIST_DOMAIN = ['a.com']

        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=[]
        )

        validator = BlackListValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('blacklist.domains')

        expect(violations_values['blacklist.domains']).to_length(2)

        expect(violations_values['blacklist.domains']).to_be_like({
            'value': config.BLACKLIST_DOMAIN,
            'description': config.get_description('BLACKLIST_DOMAIN')
        })
Example #7
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.METATAG_DESCRIPTION_MAX_SIZE = 300

        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=[]
        )

        validator = MetaTagsValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('page.metatags.description_too_big')

        expect(violations_values['page.metatags.description_too_big']).to_length(2)

        expect(violations_values['page.metatags.description_too_big']).to_be_like({
            'value': config.METATAG_DESCRIPTION_MAX_SIZE,
            'description': config.get_description('METATAG_DESCRIPTION_MAX_SIZE')
        })
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_HEADING_HIEARARCHY_SIZE = 150

        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=[]
        )

        validator = HeadingHierarchyValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('page.heading_hierarchy.size')

        expect(violations_values['page.heading_hierarchy.size']).to_length(2)

        expect(violations_values['page.heading_hierarchy.size']).to_equal({
            'value': config.MAX_HEADING_HIEARARCHY_SIZE,
            'description': config.get_description('MAX_HEADING_HIEARARCHY_SIZE')
        })
Example #9
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_TITLE_SIZE = 70

        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=[])

        validator = TitleValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('page.title.size')

        expect(violations_values['page.title.size']).to_length(2)

        expect(violations_values['page.title.size']).to_be_like({
            'value':
            config.MAX_TITLE_SIZE,
            'description':
            config.get_description('MAX_TITLE_SIZE')
        })
Example #10
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.SCHEMA_ORG_ITEMTYPE = [
            'http://schema.org/WebPage',
            'http://schema.org/AboutPage',
        ]

        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=[])

        validator = SchemaOrgItemTypeValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('invalid.schema.itemtype')

        expect(violations_values['invalid.schema.itemtype']).to_length(2)

        expect(violations_values['invalid.schema.itemtype']).to_equal({
            'value':
            config.SCHEMA_ORG_ITEMTYPE,
            'description':
            config.get_description('SCHEMA_ORG_ITEMTYPE')
        })
    def test_can_get_default_violations_values(self):
        config = Config()
        config.FORCE_CANONICAL = False

        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=[],
        )

        validator = LinkWithRelCanonicalValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include("absent.meta.canonical")

        expect(violations_values["absent.meta.canonical"]).to_length(2)

        expect(violations_values["absent.meta.canonical"]).to_be_like(
            {"value": config.FORCE_CANONICAL, "description": config.get_description("FORCE_CANONICAL")}
        )
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_HEADING_HIEARARCHY_SIZE = 150

        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=[])

        validator = HeadingHierarchyValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('page.heading_hierarchy.size')

        expect(violations_values['page.heading_hierarchy.size']).to_length(2)

        expect(violations_values['page.heading_hierarchy.size']).to_equal({
            'value':
            config.MAX_HEADING_HIEARARCHY_SIZE,
            'description':
            config.get_description('MAX_HEADING_HIEARARCHY_SIZE')
        })
Example #13
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.BLACKLIST_DOMAIN = ['a.com']

        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=[])

        validator = BlackListValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('blacklist.domains')

        expect(violations_values['blacklist.domains']).to_length(2)

        expect(violations_values['blacklist.domains']).to_be_like({
            'value':
            config.BLACKLIST_DOMAIN,
            'description':
            config.get_description('BLACKLIST_DOMAIN')
        })
Example #14
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_TITLE_SIZE = 70

        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=[]
        )

        validator = TitleValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('page.title.size')

        expect(violations_values['page.title.size']).to_length(2)

        expect(violations_values['page.title.size']).to_be_like({
            'value': config.MAX_TITLE_SIZE,
            'description': config.get_description('MAX_TITLE_SIZE')
        })
Example #15
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_IMAGE_ALT_SIZE = 70

        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=[]
        )

        validator = ImageAltValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('invalid.images.alt_too_big')

        expect(violations_values['invalid.images.alt_too_big']).to_length(2)

        expect(violations_values['invalid.images.alt_too_big']).to_be_like({
            'value': config.MAX_IMAGE_ALT_SIZE,
            'description': config.get_description('MAX_IMAGE_ALT_SIZE')
        })
Example #16
0
    def test_can_get_default_violations_values(self):
        config = Config()
        config.MAX_KB_SINGLE_IMAGE = 70
        config.MAX_IMG_REQUESTS_PER_PAGE = 10
        config.MAX_IMG_KB_PER_PAGE = 5

        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=[])

        validator = ImageRequestsValidator(reviewer)

        violations_values = validator.get_default_violations_values(config)

        expect(violations_values).to_include('single.size.img')
        expect(violations_values).to_include('total.size.img')
        expect(violations_values).to_include('total.requests.img')

        expect(violations_values['single.size.img']).to_length(2)
        expect(violations_values['total.size.img']).to_length(2)
        expect(violations_values['total.requests.img']).to_length(2)

        expect(violations_values['single.size.img']).to_be_like({
            'value':
            config.MAX_KB_SINGLE_IMAGE,
            'description':
            config.get_description('MAX_KB_SINGLE_IMAGE')
        })

        expect(violations_values['total.size.img']).to_be_like({
            'value':
            config.MAX_IMG_KB_PER_PAGE,
            'description':
            config.get_description('MAX_IMG_KB_PER_PAGE')
        })

        expect(violations_values['total.requests.img']).to_be_like({
            'value':
            config.MAX_IMG_REQUESTS_PER_PAGE,
            'description':
            config.get_description('MAX_IMG_REQUESTS_PER_PAGE')
        })