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 ...pages.login_page import LoginPage from ...pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class DeepLinkingTrackPageTest(unittest.TestCase): log = cl.Logger(logging.DEBUG) kpi_top_streams = 1441040 sas_streams = {"us": 375179, "global": 1880710} youtube_streams = {"us": 130255, "global": 782073} tiktok_streams = {"us": 1324, "global": 5717} @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.ts = TestStatus(self.driver) @allure.issue("https://data-analytics.atlassian.net/browse/AP-10992") @pytest.mark.flaky(reruns=0) @parameterized.expand(["us", "global"]) @allure.story("AP-6937") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Changing market and tabs in Performance section STEPS 1-7, 14") @allure.description("TC verifies selected market on tabs of Track page → Performance section STEPS 1-7, 14") def test_change_market_youtube_tab_STEPS_1_7_14(self, header_market): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(AppConfig.get("track49")["id"], AppConfig.get("market")[header_market]["url"]) # step 1, 14 self.tp.market_dd_choose_few_countries([self.tp.all_markets]) self.tp.select_dsp(AppConfig.get("dsp")["spotify"]) self.tp.open_current_url_with_param("&str_gr_start_date=2021-05-01&str_gr_end_date=2021-05-01") market_ui = self.tp.graph_get_selected_market() streams_in_period_ui = int(self.tp.get_streams_in_period_total().replace(",", "")) assert_that(market_ui).is_equal_to(self.tp.all_markets) assert_that(streams_in_period_ui).is_equal_to(self.sas_streams["global"]) # step 2 self.tp.switch_to_streams_by_markets_tab() self.tp.graph_get_selected_market("tp_sbm") market_ui = self.tp.graph_get_selected_market("tp_sbm") streams_in_period_ui = self.tp.get_streams_in_period_all_by_markets()[1] assert_that(market_ui).is_equal_to(self.tp.top_markets) assert_that(streams_in_period_ui).is_equal_to(self.kpi_top_streams) # step 3 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["sweden"]["name"]], "tp_sbm") self.tp.is_graph_period_displayed() self.tp.switch_to_streams_and_sources_tab() market_ui = self.tp.graph_get_selected_market() streams_in_period_ui = int(self.tp.get_streams_in_period_total().replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.sas_streams[header_market]) # step 4 self.tp.stream_and_source_choose_region(self.tp.REGION_EUROPE) self.tp.is_graph_period_displayed() self.tp.switch_to_youtube_video_performance() market_ui = self.tp.graph_get_selected_market() streams_in_period_ui = int(self.tp.get_streams_in_period_total().replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.youtube_streams[header_market]) # step 5 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["argentina"]["name"], AppConfig.get("market")["australia"]["name"]], "youtube_vp") self.tp.is_graph_period_displayed() self.tp.switch_to_streams_and_sources_tab() market_ui = self.tp.graph_get_selected_market() streams_in_period_ui = int(self.tp.graph_get_legend_by_dsp()[2].split("\n")[0].replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.sas_streams[header_market]) # step 6 self.tp.stream_and_source_choose_region(self.tp.REGION_EX_US) self.tp.is_graph_period_displayed() self.tp.tp_switch_to_tiktok_tab() market_ui = self.tp.graph_get_selected_market("tiktok") streams_in_period_ui = self.tp.get_streams_in_period_total_combined() assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.tiktok_streams[header_market]) # step 7 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["argentina"]["name"], AppConfig.get("market")["australia"]["name"]], "tiktok") self.tp.switch_to_youtube_video_performance() market_ui = self.tp.graph_get_selected_market("youtube_vp") streams_in_period_ui = int(self.tp.get_streams_in_period_total().replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.youtube_streams[header_market]) @parameterized.expand(["us", "global"]) @allure.story("AP-6937") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Changing market and tabs in Performance section STEPS 8-14") @allure.description("TC verifies selected market on tabs of Track page → Performance section STEPS 8-14") def test_change_market_youtube_tab_steps_8_14(self, header_market): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(AppConfig.get("track49")["id"], AppConfig.get("market")[header_market]["url"]) # step 8, 14 self.tp.switch_to_youtube_video_performance() self.tp.is_graph_period_displayed() self.tp.open_current_url_with_param("&str_gr_start_date=2021-05-01&str_gr_end_date=2021-05-01") self.tp.market_dd_choose_few_countries([AppConfig.get("market")["brazil"]["name"]], "youtube_vp") self.tp.switch_to_streams_by_markets_tab() market_ui = self.tp.graph_get_selected_market("tp_sbm") streams_in_period_ui = self.tp.get_streams_in_period_all_by_markets()[1] assert_that(market_ui).is_equal_to(self.tp.top_markets) assert_that(streams_in_period_ui).is_equal_to(self.kpi_top_streams) # step 9 self.tp.stream_and_source_choose_region(self.tp.REGION_ASIA, "tp_sbm") self.tp.switch_to_youtube_video_performance() market_ui = self.tp.graph_get_selected_market("youtube_vp") streams_in_period_ui = int(self.tp.get_streams_in_period_total().replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.youtube_streams[header_market]) # step 10 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["argentina"]["name"]], "youtube_vp") self.tp.tp_switch_to_tiktok_tab() market_ui = self.tp.graph_get_selected_market("tiktok") streams_in_period_ui = self.tp.get_streams_in_period_total_combined() assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.tiktok_streams[header_market]) # step 11 self.tp.stream_and_source_choose_region(self.tp.sony_offices, "tiktok") self.tp.switch_to_streams_by_markets_tab() market_ui = self.tp.graph_get_selected_market("tp_sbm") streams_in_period_ui = self.tp.get_streams_in_period_all_by_markets()[1] assert_that(market_ui).is_equal_to(self.tp.top_markets) assert_that(streams_in_period_ui).is_equal_to(self.kpi_top_streams) # step 12 self.tp.stream_and_source_choose_region(self.tp.REGION_NORTH_AMERICA, "tp_sbm") self.tp.tp_switch_to_tiktok_tab() market_ui = self.tp.graph_get_selected_market("tiktok") streams_in_period_ui = self.tp.get_streams_in_period_total_combined() assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.tiktok_streams[header_market]) # step 13 self.tp.market_dd_choose_few_countries([AppConfig.get("market")["argentina"]["name"]], "tiktok") self.tp.switch_to_streams_and_sources_tab() market_ui = self.tp.graph_get_selected_market() streams_in_period_ui = int(self.tp.graph_get_legend_by_dsp()[2].split("\n")[0].replace(",", "")) assert_that(market_ui).is_equal_to(AppConfig.get("market")[header_market]["graph"]) assert_that(streams_in_period_ui).is_equal_to(self.sas_streams[header_market])