import logging 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 ui_automation_framework.utils import logger as cl 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): 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.ts = TestStatus(self.driver) @allure.story("AP-8968") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Verification of data in 'Current' tab after switching from another tabs") @allure.description("Case-1 Switching to Streams and Sources tab from TikTok tab") def test_current_tab_after_switching_verification_case1(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track6")["id"], market_id=AppConfig.get("market")["us"]["url"]) # step 1 track_7_step1 = self.tp.td_get_track_streams_7_days_values()[:10] playlist_7_step1 = self.tp.get_playlist_stream_days_from_table()[:10] self.tp.td_switch_to_tiktok_tab() self.tp.is_tab_selected("track-performance-tiktok") # step 2 self.tp.switch_to_streams_and_sources_tab() track_7_step2 = self.tp.td_get_track_streams_7_days_values()[:10] playlist_7_step2 = self.tp.get_playlist_stream_days_from_table()[:10] assert_that(track_7_step1).is_equal_to(track_7_step2) assert_that(playlist_7_step1).is_equal_to(playlist_7_step2) @allure.story("AP-8968") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Verification of data in 'Current' tab after switching from another tabs") @allure.description("Case-2 Switching to Streams and Sources tab from YouTube tab") def test_current_tab_after_switching_verification_case2(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track6")["id"], market_id=AppConfig.get("market")["belgium"]["url"]) # step 1 track_7_step1 = self.tp.td_get_track_streams_7_days_values()[:10] playlist_7_step1 = self.tp.get_playlist_stream_days_from_table()[:10] self.tp.td_switch_to_youtube_tab() self.tp.is_tab_selected("track-performance-youtube") # step 2 self.tp.switch_to_streams_and_sources_tab() track_7_step2 = self.tp.td_get_track_streams_7_days_values()[:10] playlist_7_step2 = self.tp.get_playlist_stream_days_from_table()[:10] assert_that(track_7_step1).is_equal_to(track_7_step2) assert_that(playlist_7_step1).is_equal_to(playlist_7_step2) @allure.issue("https://data-analytics.atlassian.net/browse/AP-11032") @pytest.mark.flaky(reruns=0) @allure.story("AP-8968") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Verification of data in 'Current' tab after switching from another tabs") @allure.description("Case-3 Switching from TikTok to By Markets tab") def test_current_tab_after_switching_verification_case3(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track6")["id"], market_id=AppConfig.get("market")["belgium"]["url"]) # step 1 names_step1 = self.tp.td_cps_get_playlist_names()[:10] self.tp.tp_switch_to_tiktok_tab() # step 2 self.tp.switch_to_streams_by_markets_tab() # step 3 names_step2 = self.tp.td_cps_get_playlist_names()[:10] assert_that(names_step1).is_equal_to(names_step2) @allure.story("AP-8968") @allure.severity(allure.severity_level.NORMAL) @allure.title("[Track Page] Verification of data in 'Current' tab after switching from another tabs") @allure.description("Case-4 Switching from TikTok tab to Current playlists") def test_current_tab_after_switching_verification_case4(self): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track6")["id"], market_id=AppConfig.get("market")["belgium"]["url"]) # step 1 names_step1 = self.tp.td_cps_get_playlist_names()[:10] self.tp.td_switch_to_tiktok_tab() # step 2 self.tp.td_switch_to_playlist(self.tp.TD_CURRENT_PLAYLIST_TAB) names_step2 = self.tp.td_cps_get_playlist_names()[:10] assert_that(names_step1).is_equal_to(names_step2)