import unittest import allure import pytest from assertpy import assert_that from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig from app.api_client import ApiClient from app.src.pages.album_page import AlbumPage from app.src.pages.apple_playlist_page import ApplePlaylistPage from app.src.pages.comparison_page import TrackComparisonPage from app.src.pages.left_navigation_panel import LeftNavigationPanel 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): @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.tp = TrackPage(self.driver) self.ap = AlbumPage(self.driver) self.app = ApplePlaylistPage(self.driver) self.cp = TrackComparisonPage(self.driver) self.leftPanel = LeftNavigationPanel(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.story("AP-2310") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-1689] Amazon: Track Performance section (‘By DSP’ view) STEPS 1-10") @allure.description( """TC verifies that user can see track’s streaming data: graph+legend for Amazon dsp as well as data for Spotify and Apple dsp on By DSP view mode. The corresponding blue chart for Amazon dsp is added to the streams graph on the Track performance section. Charts legend is updated for both Spotify, Apple and Amazon music services as well. All streams value accumulates total number of streams per all partners. All option as selection graph view and country are available for Amazon chart. STEPS 1-10""" ) def test_amazon_by_dsp_view_step_1_10(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track7")["id"], market_id=AppConfig.get("market")["global"]["url"]) # step 1-2 self.tp.select_dsp(AppConfig.get("dsp")["by_dsp"]) self.tp.verify_ts_bs_sdd_removed() # step 3 self.tp.choose_graph_view_line_graph() totals_1 = self.tp.graph_amazon_get_totals(totals="by_dsp") tooltip_1 = self.tp.graph_get_tooltips()[0] # step 4 self.tp.choose_graph_view_area_graph() totals_2 = self.tp.graph_amazon_get_totals(totals="by_dsp") tooltip_2 = self.tp.graph_get_tooltips()[0] self.tp.choose_graph_view_area_graph_percentage() yaxis_area_p = self.tp.graph_get_yaxis() totals_3 = self.tp.graph_amazon_get_totals(totals="by_dsp") tooltip_3 = self.tp.graph_get_tooltips()[0] self.ts.markFinal(all("%" in t for t in yaxis_area_p), f"{yaxis_area_p}") assert_that(totals_1).is_equal_to(totals_2) assert_that(totals_2).is_equal_to(totals_3) # step 5 for t in [tooltip_1, tooltip_2, tooltip_3]: self.ts.markFinal( AppConfig.get("dsp")["spotify"] and AppConfig.get("dsp")["apple"] and AppConfig.get("dsp")["amazon"] in t, f"STEP 5: {t}", ) # step 6 self.tp.stream_and_source_choose_country(AppConfig.get("market")["argentina"]["name"]) totals_4 = self.tp.graph_amazon_get_totals(totals="by_dsp") assert_that(totals_3).is_not_equal_to(totals_4) # step 7 self.tp.select_market(AppConfig.get("market")["us"]["name"]) self.tp.graph_verify_chosen_country(AppConfig.get("market")["us"]["name"]) dsp = self.tp.get_current_dsp() streams_tab_selected = self.tp.is_tab_selected(self.tp.GRAPH_TAB_STREAMS) self.tp.verify_graph_view(self.tp.graph_area_graph) assert_that(dsp).is_equal_to(AppConfig.get("dsp")["spotify"]) assert_that(streams_tab_selected).is_true() # step 8-9 self.tp.select_dsp(AppConfig.get("dsp")["by_dsp"]) self.tp.graph_verify_predefined_periods() # step 10 xaxis_before = self.tp.graph_get_xaxis() self.tp.select_previous_mounth_period() xaxis_after = self.tp.graph_get_xaxis() self.tp.get_graph_period_displayed() assert_that(xaxis_before).is_not_equal_to(xaxis_after) @allure.story("AP-2310") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-1689] Amazon: Track Performance section (‘By DSP’ view) STEPS 11-17") @allure.description( """TC verifies that user can see track’s streaming data: graph+legend for Amazon dsp as well as data for Spotify and Apple dsp on By DSP view mode. The corresponding blue chart for Amazon dsp is added to the streams graph on the Track performance section. Charts legend is updated for both Spotify, Apple and Amazon music services as well. All streams value accumulates total number of streams per all partners. All option as selection graph view and country are available for Amazon chart. STEPS 11-17""" ) def test_amazon_by_dsp_view_step_11_17(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track7")["id"], market_id=AppConfig.get("market")["global"]["url"]) self.tp.select_dsp(AppConfig.get("dsp")["by_dsp"]) # step 11 self.tp.switch_to_streams_by_markets_tab() dsp = self.tp.get_current_dsp() dsp_options = self.tp.get_available_dsps() self.tp.verify_graph_view(self.tp.graph_area_graph) self.tp.is_country_dd_removed() assert_that(AppConfig.get("dsp")["by_dsp"]).is_not_in(dsp_options) assert_that(dsp).is_equal_to(AppConfig.get("dsp")["spotify"]) # step 12-13 self.tp.switch_to_streams_and_sources_tab() self.tp.select_dsp(AppConfig.get("dsp")["by_dsp"]) self.tp.export_to_file_amazon(source=AppConfig.get("dsp")["by_dsp"]) # step 15 self.tp.graph_verify_legend(view=AppConfig.get("dsp")["by_dsp"]) # step 16 totals_all = self.tp.graph_amazon_get_totals() totals_ui = [] for d in [AppConfig.get("dsp")["spotify"], AppConfig.get("dsp")["apple"], AppConfig.get("dsp")["amazon"]]: self.tp.select_dsp(d) streams = self.tp.get_streams_in_period_total() totals_ui.append(streams) totals_dsp = [totals_all[2].split("\n")[0], totals_all[4].split("\n")[0], totals_all[6].split("\n")[0]] assert_that(totals_dsp).is_equal_to(totals_ui) # step 17 total_all = int(totals_all[0].replace(",", "")) total_all_sum = sum(int(t.replace(",", "")) for t in totals_dsp) assert_that(total_all).is_equal_to(total_all_sum) # step 14 self.tp.open_current_url_with_param("&str_gr_start_date=2014-01-15&str_gr_end_date=2014-01-15") self.tp.verify_performance_no_data_displayed() # NOT AUTOMATED - STEPS 3