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 app.api_client import ApiClient from app.src.pages.chart_digest import ChartDigestPage 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.third_party.applecharts_page import AppleCharts from app.src.pages.top_charts_page import TopChartsPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up") class top_charts_pageTest(unittest.TestCase): us = AppConfig.get("market")["us"] @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.left_panel = LeftNavigationPanel(self.driver) self.trackPage = TrackPage(self.driver) self.top_charts_page = TopChartsPage(self.driver) self.apple_charts = AppleCharts(self.driver) self.comparison_page = TrackComparisonPage(self.driver) self.chart_digest = ChartDigestPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @parameterized.expand(["daily", "weekly"]) @allure.story("AP-1556") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verification of file export with Top Apple/Spotify Charts STEPS 1-7") @allure.description( """TC verifies that the user can export data from Spotify and Apple daily charts to a portable file. STEPS 1-7""" ) def test_file_export_spotify_and_apple_steps_1_7(self, t): user = self.loginPage.get_user_email_with_worker() token = self.api_client.authorize(user=user) self.loginPage.login_with_worker() self.top_charts_page.open_top_chart_page() self.top_charts_page.top_chart_page_is_opened() self.top_charts_page.select_market(self.us["name"]) # step 1-7 self.top_charts_page.switch_tab(self.top_charts_page.SPOTIFY_TYPE) self.top_charts_page.change_sub_tab(t) self.top_charts_page.compare_ui_and_csv(market=self.us, token=token) csv = self.top_charts_page.export_file(market=self.us, token=token)["Track Position"].to_list() assert_that(csv).is_length(200) @parameterized.expand(["daily", "weekly"]) @allure.story("AP-1556") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verification of file export with Top Apple/Spotify Charts STEPS 8-9") @allure.description( """TC verifies that the user can export data from Spotify and Apple daily charts to a portable file. STEPS 8-9""" ) def test_file_export_spotify_and_apple_steps_8_9(self, t): user = self.loginPage.get_user_email_with_worker() token = self.api_client.authorize(user=user) self.loginPage.login_with_worker() self.top_charts_page.open_top_chart_page() self.top_charts_page.select_market(self.us["name"]) self.top_charts_page.wait_for_table_load() # step 8-9 self.top_charts_page.change_sub_tab(t) self.top_charts_page.wait_for_table_load() if t == self.top_charts_page.WEEKLY: self.top_charts_page.open_spotify_chart_for_date_dd("12/26/19") else: self.top_charts_page.open_spotify_chart_for_date("12/26/19") self.top_charts_page.compare_ui_and_csv(market=self.us, token=token) @parameterized.expand(["daily", "weekly"]) @allure.story("AP-1556") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verification of file export with Top Apple/Spotify Charts STEPS 10") @allure.description( """TC verifies that the user can export data from Spotify and Apple daily charts to a portable file. STEPS 10""" ) def test_file_export_spotify_and_apple_steps_10_p1(self, t): user = self.loginPage.get_user_email_with_worker() token = self.api_client.authorize(user=user) self.loginPage.login_with_worker() self.top_charts_page.open_top_chart_page() self.top_charts_page.top_chart_page_is_opened() self.top_charts_page.select_market(self.us["name"]) self.top_charts_page.change_sub_tab(t) # step 10 self.top_charts_page.open_spotify_chart_for_date("01/30/20") self.top_charts_page.open_filter_menu(self.top_charts_page.SPOTIFY_TYPE) self.top_charts_page.filter_check_non_sony_tracks() csv = self.top_charts_page.export_file(self.us, token) csv_is_sony = csv["Is Sony?"].to_list() self.ts.markFinal(all(e == "no" for e in csv_is_sony), "STEP 10: non sony tracks are in csv") @parameterized.expand(["daily", "weekly"]) @allure.story("AP-1556") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verification of file export with Top Apple/Spotify Charts STEPS 10 p2") @allure.description( """TC verifies that the user can export data from Spotify and Apple daily charts to a portable file. STEPS 10 p2""" ) def test_file_export_spotify_and_apple_steps_10_p2(self, t): user = self.loginPage.get_user_email_with_worker() token = self.api_client.authorize(user=user) self.loginPage.login_with_worker() self.top_charts_page.open_top_chart_page() self.top_charts_page.select_market(self.us["name"]) self.top_charts_page.wait_for_table_load() self.top_charts_page.change_sub_tab(t) self.top_charts_page.wait_for_table_load() # step 10 self.top_charts_page.open_spotify_chart_for_date("02/06/20") self.top_charts_page.open_filter_menu(self.top_charts_page.SPOTIFY_TYPE) self.top_charts_page.filter_check_sony_tracks() csv = self.top_charts_page.export_file(self.us, token) csv_is_sony = csv["Is Sony?"].to_list() self.ts.markFinal(all(e == "yes" for e in csv_is_sony), "sony tracks only are in csv")