import logging 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 ui_automation_framework.utils import logger as cl from app.api_client import ApiClient from app.src.pages.album_page import AlbumPage from app.src.pages.login_page import LoginPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class DeepLinkingTrackPageTest(unittest.TestCase): log = cl.Logger(logging.DEBUG) @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.ap = AlbumPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @parameterized.expand([("us", "album"), ("global", "album"), ("us", "tracks"), ("global", "tracks")]) @allure.story("AP-6869") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6736][Album] Markets applying verification. STEPS 1-7, 9") @allure.description("""Markets applying on Album page during DSP changing on each tab So that filters conditional logic works correct. STEPS 1-7, 9""") def test_album_markets_applying_verifications_steps_1_7_9(self, market_select, tab): self.loginPage.login_with_worker() self.tp.select_market(AppConfig.get("market")[market_select]["name"]) self.tp.open_spotify_page(id=AppConfig.get("album2")["id"], page_type="album") # step 1, 7-8, 10 self.ap.switch_to_tab(tab) dsps = ["apple", "spotify", "total_streams"] if tab == "album": dsps = dsps + ["by_dsp"] market_ui = self.tp.graph_get_selected_market() assert_that(market_ui).is_equal_to(AppConfig.get("market")[market_select]["graph"]) # step 2 for dsp in dsps: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(AppConfig.get("market")[market_select]["graph"]) self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["us"]["name"], AppConfig.get("market")["canada"]["name"]]) # step 3 for dsp in dsps: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to("2 Markets") # step 4 self.tp.stream_and_source_choose_region(self.tp.REGION_EUROPE) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.REGION_EUROPE) for dsp in dsps: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to(self.tp.REGION_EUROPE) # step 5 self.tp.stream_and_source_deselect_countries([AppConfig.get("market")["italy"]["name"]]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to("37 Markets") for dsp in dsps: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market() assert_that(market).is_equal_to("37 Markets") # step 6 self.ap.refresh() market = self.tp.graph_get_selected_market() dsp_ui = self.tp.get_current_dsp() assert_that(dsp_ui).is_equal_to(AppConfig.get("dsp")["spotify"]) assert_that(market).is_equal_to(AppConfig.get("market")[market_select]["graph"]) @allure.story("AP-6869") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-6736][Album] Markets applying verification. STEPS 8, 10-11") @allure.description("""Markets applying on Album page during DSP changing on each tab So that filters conditional logic works correct. STEPS 8, 10-11""") def test_album_markets_applying_verifications_steps_8_10_11(self): self.loginPage.login_with_worker() self.tp.open_spotify_page(id=AppConfig.get("album2")["id"], page_type="album") # step 9 self.tp.select_market(AppConfig.get("market")["global"]["name"]) self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["argentina"]["name"]]) self.ap.switch_to_tab(self.ap.TRACK_TAB) market_ui = self.tp.graph_get_selected_market() assert_that(market_ui).is_equal_to(AppConfig.get("market")["global"]["graph"]) # step 11 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["canada"]["name"]]) self.ap.switch_to_tab(self.ap.COUNTRIES_TAB) market_ui = self.tp.graph_get_selected_market("tp_sbm") assert_that(market_ui).is_equal_to(self.tp.top_markets) # step 12 self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["us"]["name"], AppConfig.get("market")["canada"]["name"]], tab="tp_sbm") for dsp in ["apple", "total_streams"]: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market("tp_sbm") assert_that(market).is_equal_to("2 Markets") self.tp.stream_and_source_choose_region(param=self.tp.REGION_EUROPE, dd="tp_sbm") market = self.tp.graph_get_selected_market("tp_sbm") assert_that(market).is_equal_to(self.tp.REGION_EUROPE) for dsp in ["apple", "spotify"]: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market("tp_sbm") assert_that(market).is_equal_to(self.tp.REGION_EUROPE) self.tp.stream_and_source_deselect_countries(market_name=[AppConfig.get("market")["italy"]["name"]], dd="tp_sbm") market = self.tp.graph_get_selected_market("tp_sbm") assert_that(market).is_equal_to("37 Markets") for dsp in ["apple", "total_streams"]: self.ap.select_dsp(AppConfig.get("dsp")[dsp]) market = self.tp.graph_get_selected_market("tp_sbm") assert_that(market).is_equal_to("37 Markets") self.ap.refresh() self.ap.switch_to_tab(self.ap.COUNTRIES_TAB) market = self.tp.graph_get_selected_market("tp_sbm") dsp_ui = self.tp.get_current_dsp() assert_that(dsp_ui).is_equal_to(AppConfig.get("dsp")["spotify"]) assert_that(market).is_equal_to(self.tp.top_markets) self.tp.select_market(AppConfig.get("market")["global"]["name"]) self.ap.switch_to_tab(self.ap.COUNTRIES_TAB) market = self.tp.graph_get_selected_market("tp_sbm") dsp_ui = self.tp.get_current_dsp() assert_that(dsp_ui).is_equal_to(AppConfig.get("dsp")["spotify"]) assert_that(market).is_equal_to(self.tp.top_markets) self.ap.switch_to_tab(self.ap.ALBUM_TAB) self.tp.market_dd_choose_few_countries(param=[AppConfig.get("market")["argentina"]["name"]]) self.ap.switch_to_tab(self.ap.COUNTRIES_TAB) market = self.tp.graph_get_selected_market("tp_sbm") dsp_ui = self.tp.get_current_dsp() assert_that(dsp_ui).is_equal_to(AppConfig.get("dsp")["spotify"]) assert_that(market).is_equal_to(self.tp.top_markets)