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

        validator = GoogleAnalyticsValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.google_analytics': set([('UA-296593-2', None)]),
        }

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(
                key='google_analytics.domain.not_found',
                points=50,
                value=None
            ))
    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=[])

        validator = GoogleAnalyticsValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.google_analytics': set([('UA-296593-2', 'www.globo.com')]),
        }

        validator.validate()

        expect(validator.add_violation.called).to_be_false()
    def test_page_without_google_analytics(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=[])

        validator = GoogleAnalyticsValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.google_analytics': set([]),
        }

        validator.validate()

        expect(validator.add_violation.call_args_list).to_include(
            call(key='google_analytics.not_found', points=100, value=None))
    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=[]
        )

        validator = GoogleAnalyticsValidator(reviewer)
        validator.add_violation = Mock()
        validator.review.data = {
            'page.google_analytics': set([('UA-296593-2', 'www.globo.com')]),
        }

        validator.validate()

        expect(validator.add_violation.called).to_be_false()