import unittest import allure import pytest from assertpy import assert_that from parameterized import parameterized from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from ...pages.album_page import AlbumPage from ...pages.login_page import LoginPage from ...pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class DeepLinkingTrackPageTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.ap = AlbumPage(self.driver) self.ts = TestStatus(self.driver) @parameterized.expand( [ ("track", "", AppConfig.get("track40")["id"]), ("album", "Album", AppConfig.get("album2")["id"]), ("album", "Track", AppConfig.get("album2")["id"]), ] ) @allure.story("AP-4764") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-4526, 4429] Countries multi-selection verification STEPS 1-13") @allure.description("TC verifies that user can select several countries at the same time and analyze streams generated there. STEPS 1-13") def test_select_several_countries_steps_1_13(self, page_type, album_tab, id): self.loginPage.login_with_worker() self.tp.open_spotify_page(id=id, page_type=page_type) self.tp.select_market(AppConfig.get("market")["us"]["name"]) if page_type == "album": self.ap.switch_to_tab(album_tab) # step 1 market_tp = self.tp.graph_get_selected_market() assert_that(market_tp).is_equal_to(AppConfig.get("market")["us"]["name"]) # step 2 self.tp.select_market(AppConfig.get("market")["global"]["name"]) self.tp.select_dsp(AppConfig.get("dsp")["spotify"]) market_tp = self.tp.graph_get_selected_market() assert_that(market_tp).is_equal_to(self.tp.all_markets) # step 3-5 self.tp.markets_dd_click() self.tp.graph_verify_market_droplist() # step 6 items_before = self.tp.graph_countries_dd_get_markets() self.tp.graph_countries_filter_by(param="s", clear=False) self.tp.graph_countries_clear_icon_displayed() # step 7 for p in ["States", "Andorra"]: self.tp.graph_countries_filter_by(param=p) results = self.tp.graph_countries_dd_get_markets()[1:] assert_that(all(p in r for r in results)).is_true() self.tp.graph_countries_filter_by(param=AppConfig.get("market")["germany"]["market"]) results = self.tp.graph_countries_dd_get_markets()[1:] assert_that(AppConfig.get("market")["germany"]["name"] in results).is_true() results.remove(AppConfig.get("market")["germany"]["name"]) assert_that(all(AppConfig.get("market")["germany"]["market"] in r.lower() for r in results)).is_true() # step 8 self.tp.graph_countries_filter_by(param="#") self.tp.graph_countries_verify_no_items() # step 9 self.tp.graph_countries_filter_by(param="") items_after = self.tp.graph_countries_dd_get_markets() assert_that(items_before).is_equal_to(items_after) # step 10 totals_before = self.tp.get_streams_in_period_total() self.tp.markets_dd_click() self.tp.stream_and_source_choose_country(AppConfig.get("market")["uk"]["name"]) self.tp.verify_graph_view(AppConfig.get("market")["uk"]["market"]) # step 11 totals_after = self.tp.get_streams_in_period_total() assert_that(totals_before).is_not_equal_to(totals_after) # step 12 market_tp = self.tp.graph_get_selected_market() assert_that(market_tp).is_equal_to(AppConfig.get("market")["uk"]["name"]) # step 13 self.tp.markets_dd_click() items = self.tp.graph_countries_dd_get_markets() assert_that(items[1]).is_equal_to(AppConfig.get("market")["uk"]["name"]) assert_that(items[2:]).is_sorted() @parameterized.expand( [ ("track", "", AppConfig.get("track40")["id"]), ("album", "Album", AppConfig.get("album2")["id"]), ("album", "Track", AppConfig.get("album2")["id"]), ] ) @allure.story("AP-4764") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-4526, 4429] Countries multi-selection verification STEPS 14-18, 23-24") @allure.description("TC verifies that user can select several countries at the same time and analyze streams generated there. STEPS 14-18, 23-24") def test_select_several_countries_steps_14_18_23_24(self, page_type, album_tab, id): self.loginPage.login_with_worker() self.tp.open_spotify_page(id=id, page_type=page_type) self.tp.select_market(AppConfig.get("market")["global"]["name"]) self.tp.select_dsp(AppConfig.get("dsp")["spotify"]) if page_type == "album": self.ap.switch_to_tab(album_tab) # step 14 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["us"]["name"], AppConfig.get("market")["canada"]["name"]]) market_graph = self.tp.graph_get_selected_market() assert_that(market_graph).is_equal_to("2 Markets") # step 15 self.tp.graph_dd_verify_hint([AppConfig.get("market")["us"]["name"], AppConfig.get("market")["canada"]["name"]]) # step 16 if album_tab != "Track": total_2 = self.tp.get_streams_in_period_total() three_markets = [ AppConfig.get("market")["us"]["name"], AppConfig.get("market")["canada"]["name"], AppConfig.get("market")["brazil"]["name"], ] self.tp.market_dd_choose_few_countries(three_markets) if album_tab != "Track": total_3 = self.tp.get_streams_in_period_total() assert_that(total_2).is_not_equal_to(total_3) # step 17 self.tp.graph_dd_verify_hint(three_markets) # step 18 self.tp.markets_dd_click() markets = self.tp.graph_countries_dd_get_markets() assert_that(markets[0]).is_equal_to(f"{self.tp.all_markets} ({len(three_markets)} of {len(markets) - 1})") assert_that(markets[1:4]).is_equal_to(sorted(three_markets)) assert_that(markets[4:]).is_sorted() self.tp.markets_dd_click() # step 23 if album_tab != "Track": total_before = self.tp.get_streams_in_period_total() self.tp.stream_and_source_deselect_countries( market_name=[AppConfig.get("market")["canada"]["name"], AppConfig.get("market")["brazil"]["name"]], apply=False, ) self.tp.click_on_title() if album_tab != "Track": total_after = self.tp.get_streams_in_period_total() assert_that(total_before).is_equal_to(total_after) # step 24 self.tp.stream_and_source_deselect_countries(three_markets, apply=False) self.tp.click_on_title() if album_tab != "Track": total_after_3 = self.tp.get_streams_in_period_total() assert_that(total_after_3).is_equal_to(total_after) @parameterized.expand( [ ("track", "", AppConfig.get("track40")["id"], AppConfig.get("dsp")["spotify"]), ("track", "", AppConfig.get("track40")["id"], AppConfig.get("dsp")["apple"]), ("track", "", AppConfig.get("track40")["id"], AppConfig.get("dsp")["amazon"]), ("track", "", AppConfig.get("track40")["id"], AppConfig.get("dsp")["by_dsp"]), ("track", "", AppConfig.get("track40")["id"], AppConfig.get("dsp")["total_streams"]), ("album", "Album", AppConfig.get("album2")["id"], AppConfig.get("dsp")["spotify"]), ("album", "Album", AppConfig.get("album2")["id"], AppConfig.get("dsp")["apple"]), ("album", "Track", AppConfig.get("album2")["id"], AppConfig.get("dsp")["spotify"]), ("album", "Track", AppConfig.get("album2")["id"], AppConfig.get("dsp")["apple"]), ("album", "Track", AppConfig.get("album2")["id"], AppConfig.get("dsp")["total_streams"]), ] ) @allure.story("AP-4764") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-4526, 4429] Countries multi-selection verification STEPS 19-22") @allure.description("TC verifies that user can select several countries at the same time and analyze streams generated there. STEPS 19-22") def test_select_several_countries_steps_19_22(self, page_type, album_tab, id, dsp): self.loginPage.login_with_worker() self.tp.open_spotify_page(id=id, page_type=page_type) self.tp.select_market(AppConfig.get("market")["global"]["name"]) if page_type == "album": self.ap.switch_to_tab(album_tab) three_markets = [ AppConfig.get("market")["us"], AppConfig.get("market")["canada"], AppConfig.get("market")["brazil"], ] self.tp.market_dd_choose_few_countries([m["name"] for m in three_markets]) # step 19-22 self.tp.select_dsp(dsp) self.tp.export_to_file_streams_and_sources_tab(tab=album_tab, markets=[m["market"] for m in three_markets]) self.tp.markets_dd_click() markets = self.tp.graph_countries_dd_get_markets() assert_that(markets[1:4]).is_equal_to(sorted([m["name"] for m in three_markets]))