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_retrieve_from_path(self): servei = fixtures.create_and_publish_content( self.portal, fixtures.servei_without_product_id) fixtures.create_and_publish_content( servei['problemes'], fixtures.problema_1) fixtures.create_and_publish_content( servei['problemes'], fixtures.problema_2) commit() view = api.content.get_view( 'retrieve_problemes', servei, self.layer['request']) # problems not empty, count is present query_string = "?count=5" self.browser.open(view.url() + query_string) self.assertAppearInOrder([ "02/01/2016", "Problema 2", "01/01/2016", "Problema 1", ], self.browser.contents) self.assertIn( "Tots els problemes", self.browser.contents) self.assertNotIn( "No hi ha cap problema enregistrat relacionat amb aquest servei", self.browser.contents) # problems not empty, count not present self.browser.open(view.url()) self.assertAppearInOrder([ "02/01/2016", "Problema 2", "01/01/2016", "Problema 1", ], self.browser.contents) self.assertNotIn( "Tots els problemes", self.browser.contents) self.assertNotIn( "No hi ha cap problema enregistrat relacionat amb aquest servei", self.browser.contents) # problems is empty servei['problemes'].manage_delObjects(servei['problemes'].keys()) commit() self.browser.open(view.url()) self.assertNotIn("02/01/2016", self.browser.contents) self.assertNotIn("Problema 2", self.browser.contents) self.assertNotIn("01/01/2016", self.browser.contents) self.assertNotIn("Problema 1", self.browser.contents) self.assertIn( "No hi ha cap problema enregistrat relacionat amb aquest servei", self.browser.contents) self.assertNotIn( "Tots els problemes", self.browser.contents)
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_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_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)