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): date_range = "&str_gr_start_date=2021-01-15&str_gr_end_date=2021-01-16" @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-2304") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-1689] Amazon: Track Performance section (‘Amazon’ view) STEPS 1-9") @allure.description( """TC verifies that user can see track’s streaming data: graph+legend for Amazon dsp. The corresponding dsp logo is added to the Track performance section and leads to the album with this track on the Amazon music service. All option as selection graph view, country, source and downloading csv file are available for Amazon chart. STEPS 1-9""" ) def test_amazon_tps_view_step_1_9(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-3 self.tp.dsp_verify_hover() # step 4 self.tp.select_dsp(AppConfig.get("dsp")["amazon"]) # step 5 self.tp.verify_graph_view(self.tp.graph_area_graph) self.tp.verify_graph_view(self.tp.graph_amazon) # step 6 lf = self.tp.graph_get_legend_columns(self.tp.lf_locator) lb = self.tp.graph_get_legend_columns(self.tp.lb_locator) assert_that(lf).is_equal_to(self.tp.lf_legend) assert_that(lb).is_equal_to(self.tp.lb_legend) # step 8, 9 self.tp.change_source_type(AppConfig.get("source")["by_source"]) self.tp.open_current_url_with_param(self.date_range) self.tp.choose_graph_view_area_graph() self.tp.verify_graph_view(self.tp.graph_by_source) tooltip = self.tp.graph_get_tooltips()[0] for l in self.tp.lb_legend + self.tp.lf_legend: self.ts.markFinal(l in tooltip, f"STEP 9: {tooltip}") self.tp.choose_graph_view_area_graph_percentage() self.tp.verify_graph_view(self.tp.graph_by_source) tooltip = self.tp.graph_get_tooltips()[0] for l in self.tp.lb_legend + self.tp.lf_legend: self.ts.markFinal(l in tooltip, f"{tooltip}") self.tp.change_source_type(AppConfig.get("source")["all_streams"]) self.tp.choose_graph_view_line_graph() self.tp.verify_graph_view(self.tp.graph_all_streams) @allure.story("AP-2304") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-1689] Amazon: Track Performance section (‘Amazon’ view) STEPS 10-16") @allure.description( """TC verifies that user can see track’s streaming data: graph+legend for Amazon dsp. The corresponding dsp logo is added to the Track performance section and leads to the album with this track on the Amazon music service. All option as selection graph view, country, source and downloading csv file are available for Amazon chart. STEPS 10-16""" ) def test_amazon_tps_view_step_10_16(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")["amazon"]) self.tp.open_current_url_with_param(self.date_range) # step 10 total_1 = self.tp.get_streams_in_period_total() self.tp.stream_and_source_choose_country(AppConfig.get("market")["australia"]["name"]) total_2 = self.tp.get_streams_in_period_total() tooltip_2 = self.tp.graph_get_tooltips() assert_that(total_1).is_not_equal_to(total_2) # step 11 self.tp.change_source_value(AppConfig.get("source")["search"]) total_3 = self.tp.get_streams_in_period_total() tooltip_3 = self.tp.graph_get_tooltips() assert_that(total_3).is_equal_to(total_2) assert_that(tooltip_2).is_not_equal_to(tooltip_3) # step 12 self.tp.select_market(AppConfig.get("market")["france"]["name"]) self.tp.graph_verify_chosen_country(AppConfig.get("market")["france"]["name"]) total_4 = self.tp.get_streams_in_period_total() assert_that(total_3).is_not_equal_to(total_4) # step 13 xaxis_before = self.tp.graph_get_xaxis() url_before = self.tp.get_url() 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) # step 14 self.tp.open_url(url_before + self.date_range) self.tp.switch_to_streams_by_markets_tab() self.tp.graph_verify_graph_view_droplist(country_tab=True) # step 15, 16 # self.tp.choose_graph_view_line_graph() # tooltip_4 = self.tp.graph_get_tooltips()[0] # assert_that('Streams' in tooltip_4).is_true() self.tp.choose_graph_view_bar_chart() tooltip_5_streams = self.tp.get_track_performance_countries_tooltips(1)["streams"][0] assert_that(isinstance(tooltip_5_streams, int)).is_true() @allure.story("AP-2304") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-1689] Amazon: Track Performance section (‘Amazon’ view) STEPS 19-22") @allure.description( """TC verifies that user can see track’s streaming data: graph+legend for Amazon dsp. The corresponding dsp logo is added to the Track performance section and leads to the album with this track on the Amazon music service. All option as selection graph view, country, source and downloading csv file are available for Amazon chart. STEPS 19-22""" ) def test_amazon_tps_view_step_19_22(self): self.loginPage.login_with_worker() self.tp.open_current_url_with_param(f"spotify/track/{AppConfig.get('track7')['id']}?market={AppConfig.get('market')['global']['url']}&str_gr_start_date=2021-01-01&str_gr_end_date=2021-01-30&str_gr_tab=2&str_gr_dsp=3&str_gr_view=2") self.tp.choose_graph_view_bar_chart() self.tp.is_graph_period_displayed() # step 19-22 self.tp.export_to_file_countries_tab() # STEPS 23-25 covered in AP-2310, AP-4865, AP-4646 # NOT AUTOMATED - STEP 17, 18