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.login_page import LoginPage from app.src.pages.track_page import TrackPage from app.src.pages.youtube_video_popup import YoutubeVideoPopup @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.youtube_popup = YoutubeVideoPopup(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.story("AP-5895") @allure.severity(allure.severity_level.NORMAL) @allure.title("[AP-5888] Video Page. Pop-Up videos selector") @allure.description("TC verifies Pop-Up videos selector on a Video Page (Full Performance).") def test_youtube_nvp_popup_video_selector(self): self.loginPage.login_with_worker() self.tp.open_youtube_video_page(isrc=AppConfig.get("track40")["isrc"], market=AppConfig.get("market")["us"]["url"]) # step 1 sidebar_values_before = self.tp.nvp_youtube_get_sidebar_values_ui() self.youtube_popup.open_video_popup() # step 2-3 self.youtube_popup.verify_elements() # step 4 popup_table_data = self.youtube_popup.get_all_from_table() assert_that(popup_table_data[self.youtube_popup.lifetime_views_column]).is_sorted(reverse=True) # step 5 self.youtube_popup.verify_lifetime_column_hover() # step 6 assert_that(["VEVO", "MANUAL", "PREMIUM UGC"]).contains(popup_table_data["video_labels"][0]) assert_that(popup_table_data["video_bys"][0]).starts_with("By ") # step 7 api_resp = self.api_client.get_delphi_videos( isrc=AppConfig.get("track40")["isrc"], params="group_by=date%2Cvideo_id&sort_by=views&limit=20&views=1000&expand_to=related_isrcs&content_type=partner_uploaded%2Cpremium_ugc&", ) video_ids = [i["video_id"] for i in api_resp] video_titles = [i["video_title"] for i in api_resp] assert_that(len(video_ids)).is_equal_to(len(popup_table_data[self.youtube_popup.video_title_column])) assert_that(video_titles).is_equal_to(popup_table_data[self.youtube_popup.video_title_column]) # step 8 lifetime_views_api = [i["views"] for i in api_resp] assert_that(lifetime_views_api).is_equal_to(popup_table_data[self.youtube_popup.lifetime_views_column]) # step 10 self.youtube_popup.verify_fire_icons(isrc=AppConfig.get("track40")["isrc"]) # step 11 self.youtube_popup.verify_apply_button(inactive=True) # step 12 self.youtube_popup.check_uncheck_videos([1]) self.youtube_popup.verify_apply_button() # step 13 self.youtube_popup.close_video_popup() sidebar_values_after = self.tp.nvp_youtube_get_sidebar_values_ui() assert_that(sidebar_values_before).is_equal_to(sidebar_values_after) # step 14 self.youtube_popup.open_video_popup() self.youtube_popup.check_uncheck_videos(list(range(1, len(video_ids) + 1))) self.youtube_popup.verify_apply_button(inactive=True) # step 15 two_video = [1, 2] self.youtube_popup.check_uncheck_videos(two_video) self.tp.dd_click_apply() sidebar_values_two_video = self.tp.nvp_youtube_get_sidebar_values_ui() assert_that(sidebar_values_two_video).is_not_equal_to(sidebar_values_after) # step 16 self.youtube_popup.open_video_popup() self.youtube_popup.verify_selected_videos(two_video) popup_table_data = self.youtube_popup.get_all_from_table() assert_that(popup_table_data[self.youtube_popup.lifetime_views_column]).is_sorted(reverse=True) # NOT AUTOMATED STEPS - 9, 17