def test_sss_source_re_should_include_service_with_url_and_published(self):
     fixtures.create_and_publish_content(self.portal,
                                         serveis.servei_domain_1)
     commit()
     calculator = SessionsSourceServei(self.portal)
     source_re = calculator._build_filters()
     self.assertEqual('ga:source=~^domain1\\.com$', source_re)
 def test_sss_source_re_should_include_service_with_url_and_published(self):
     fixtures.create_and_publish_content(
         self.portal, serveis.servei_domain_1)
     commit()
     calculator = SessionsSourceServei(self.portal)
     source_re = calculator._build_filters()
     self.assertEqual('ga:source=~^domain1\\.com$', source_re)
 def test_bf_should_return_empty_re_if_no_services(self,
                                                   mock_getToolByName):
     calculator = SessionsSourceServei('mock_context')
     with patch(
             'genweb.serveistic.data_access.servei.ServeiDataReporter.list_by_review_state',
             side_effect=([], )):
         source_re = calculator._build_filters()
         self.assertEqual('ga:source=~^$', source_re)
 def test_bf_should_return_services_re_if_services(self, mock_getToolByName):
     calculator = SessionsSourceServei('mock_context')
     with patch('genweb.serveistic.data_access.servei.ServeiDataReporter.list_by_review_state',
                side_effect=([
                    Mock(website_url='http://domain1.com/a/b/c.html'),
                    Mock(website_url='http://domain2.com/a/b/c.html'),
                         ], )):
         source_re = calculator._build_filters()
         self.assertEqual(
             'ga:source=~^domain1\\.com$,ga:source=~^domain2\\.com$',
             source_re)
    def test_sss_source_re_should_be_empty_if_all_services_not_published_or_urls_empty_or_none(
            self):
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_empty)
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_none)
        fixtures.create_content(self.portal, serveis.servei_domain_1)
        commit()

        calculator = SessionsSourceServei(self.portal)
        source_re = calculator._build_filters()
        self.assertEqual('ga:source=~^$', source_re)
    def test_sss_source_re_should_be_empty_if_all_services_not_published_or_urls_empty_or_none(self):
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_empty)
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_none)
        fixtures.create_content(
            self.portal, serveis.servei_domain_1)
        commit()

        calculator = SessionsSourceServei(self.portal)
        source_re = calculator._build_filters()
        self.assertEqual('ga:source=~^$', source_re)
 def test_bf_should_return_services_re_if_services(self,
                                                   mock_getToolByName):
     calculator = SessionsSourceServei('mock_context')
     with patch(
             'genweb.serveistic.data_access.servei.ServeiDataReporter.list_by_review_state',
             side_effect=([
                 Mock(website_url='http://domain1.com/a/b/c.html'),
                 Mock(website_url='http://domain2.com/a/b/c.html'),
             ], )):
         source_re = calculator._build_filters()
         self.assertEqual(
             'ga:source=~^domain1\\.com$,ga:source=~^domain2\\.com$',
             source_re)
    def test_sss_source_re_should_only_include_services_if_published_and_with_urls(
            self):
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_empty)
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_none)
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_1)
        fixtures.create_content(self.portal, serveis.servei_domain_2)
        fixtures.create_and_publish_content(self.portal,
                                            serveis.servei_domain_3)
        commit()

        calculator = SessionsSourceServei(self.portal)
        source_re = calculator._build_filters()
        self.assertEqual(
            'ga:source=~^domain1\\.com$,ga:source=~^domain3\\.com$', source_re)
    def test_sss_source_re_should_only_include_services_if_published_and_with_urls(self):
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_empty)
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_none)
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_1)
        fixtures.create_content(
            self.portal, serveis.servei_domain_2)
        fixtures.create_and_publish_content(
            self.portal, serveis.servei_domain_3)
        commit()

        calculator = SessionsSourceServei(self.portal)
        source_re = calculator._build_filters()
        self.assertEqual(
            'ga:source=~^domain1\\.com$,ga:source=~^domain3\\.com$', source_re)
 def test_eud_should_remove_protocol_and_path(self):
     calculator = SessionsSourceServei('mock_context')
     domain = calculator._extract_url_domain_re(
         'http://domain.com/1/two/3.html')
     self.assertEqual('domain\\.com', domain)
 def test_eud_should_remove_backslash_after_domain(self):
     calculator = SessionsSourceServei('mock_context')
     domain = calculator._extract_url_domain_re('domain.com/')
     self.assertEqual('domain\\.com', domain)
 def test_bf_should_return_empty_re_if_no_services(self, mock_getToolByName):
     calculator = SessionsSourceServei('mock_context')
     with patch('genweb.serveistic.data_access.servei.ServeiDataReporter.list_by_review_state',
                side_effect=([], )):
         source_re = calculator._build_filters()
         self.assertEqual('ga:source=~^$', source_re)
 def test_eud_should_remove_protocol_and_path(self):
     calculator = SessionsSourceServei('mock_context')
     domain = calculator._extract_url_domain_re(
         'http://domain.com/1/two/3.html')
     self.assertEqual('domain\\.com', domain)
 def test_eud_should_remove_backslash_after_domain(self):
     calculator = SessionsSourceServei('mock_context')
     domain = calculator._extract_url_domain_re('domain.com/')
     self.assertEqual('domain\\.com', domain)