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')
        })
Exemple #2
0
    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')
        })