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.comparison_page import TrackComparisonPage 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.cp = TrackComparisonPage(self.driver) self.ap = AlbumPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.issue("https://data-analytics.atlassian.net/browse/AP-5534", "https://data-analytics.atlassian.net/browse/AP-8058") @pytest.mark.flaky(reruns=0) @parameterized.expand( [ (AppConfig.get("market")["global"]["url"], [AppConfig.get("market")["global"]["api"]], ""), (AppConfig.get("market")["us"]["url"], [AppConfig.get("market")["us"]["api"]], ""), ( AppConfig.get("market")["us"]["url"], [AppConfig.get("market")["us"]["api"], AppConfig.get("market")["canada"]["api"]], "&str_gr_region=rna", ), ] ) @allure.story("AP-5106") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-4914] [Track -> Video Performance] Legend with Data Table verification when ‘By Video’ is selected in 'Views and Sources' filter.") @allure.description( "TC verifies new table Legend view with Video types that user can use when ‘By Video’/‘Official vs UGC’ values are selected in ‘Views " "and Sources’ filter on Video Performance tab so that streaming data coming from YOUTUBE can be analyzed with respect to specific " "Views and Sources." ) def test_youtube_vp_source_by_videos_legend(self, market_url, market_api, region): self.loginPage.login_with_worker() self.tp.open_spotify_track_page_with_market_id(track_id=AppConfig.get("track40")["id"], market_id=market_url) self.tp.switch_to_youtube_video_performance() if region != "": self.tp.open_current_url_with_param(region) # step 10, 23-24 self.tp.vp_youtube_change_source_view(param=AppConfig.get("source")["by_video"]) kpi_table = self.tp.vp_youtube_get_kpi_table() self.tp.vp_youtube_kpi_verify_columns_hover() assert_that(kpi_table["video-title"][-1]).is_equal_to("Total") # step 11 views = [int(v.split("\n")[0]) for v in kpi_table["views-in-period"][:-1]] assert_that(views).is_sorted(reverse=True) # step 12 self.tp.vp_youtube_click_column(column="views-in-period") table = self.tp.vp_youtube_get_kpi_table()["views-in-period"][:-1] assert_that([int(v.split("\n")[0]) for v in table]).is_sorted() # step 14 self.tp.vp_youtube_kpi_verify_sorting() # step 15-17, 19 self.tp.kpi_verify_calculations(markets=market_api) # step 20 self.tp.open_current_url_with_param("&str_gr_start_date=2021-03-19&str_gr_end_date=2021-03-26") self.tp.kpi_verify_calculations(markets=market_api) # NOT AUTOMATED - STEPS 2-9, 18, 21-22 # STEP 1 - COVERED IN AP-5164