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') })
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') })