import unittest import allure import pytest from parameterized import parameterized from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig 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 TopChartsPageTest(unittest.TestCase): us = AppConfig.get("market")["us"]["name"] @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.ts = TestStatus(self.driver) @parameterized.expand(["spotify", "apple"]) @allure.story("AP-4051") @allure.story("AP-1415") @allure.severity(allure.severity_level.NORMAL) @allure.title("Displaying of Top 100 Apple Music charts. STEPS 1-2") @allure.description( """TC verifies that Top 100 Apple Music chart is available for user from the Daily Digest page. This functionality provides an ability to access a full list of market-specific Apple charts. """ ) def test_top_100_apple_1_2(self, dsp): self.loginPage.login_with_worker() self.loginPage.is_logged_in() self.left_panel.open_chart_digest_page() self.chart_digest.is_opened() self.trackPage.select_market(self.us) for t in [self.chart_digest.SECTION_TOP_10, self.chart_digest.SECTION_EXITS_TOP_10]: self.chart_digest.select_tab("{}-{}".format(self.chart_digest.TOP_VIEW, dsp)) self.chart_digest.select_section_for_table("{}-{}".format(self.chart_digest.TOP_VIEW, t)) self.chart_digest.open_top_charts_from_table(self.chart_digest.TOP_VIEW) self.top_charts_page.verify_chosen_switch(dsp) self.top_charts_page.go_back() for b in [self.chart_digest.MAJOR_MOVES, self.chart_digest.BUBBLING_UNDER]: self.chart_digest.select_tab(dsp) self.chart_digest.open_top_charts_from_table(b) self.top_charts_page.verify_chosen_switch(dsp) self.top_charts_page.go_back() @allure.story("AP-4051") @allure.story("AP-1415") @allure.severity(allure.severity_level.NORMAL) @allure.title("Displaying of Top 100 Apple Music charts") @allure.description( """TC verifies that Top 100 Apple Music chart is available for user from the Daily Digest page. This functionality provides an ability to access a full list of market-specific Apple charts. """ ) def test_top_100_apple_3_14(self): self.loginPage.login_with_worker() self.loginPage.is_logged_in() self.trackPage.select_market(self.us) # step 3 self.top_charts_page.open_top_chart_page() self.top_charts_page.switch_tab(self.top_charts_page.APPLE_TYPE) # step 4, 13 self.top_charts_page.verify_elements(self.top_charts_page.APPLE_TYPE) self.top_charts_page.verify_apple_market(self.us) # step 8 self.top_charts_page.switch_tab(self.top_charts_page.APPLE_TYPE) self.top_charts_page.click_on_track_and_verify() self.trackPage.go_back() # step 9 self.top_charts_page.switch_tab(self.top_charts_page.APPLE_TYPE) self.top_charts_page.click_on_artist_and_verify(tab=self.top_charts_page.APPLE_TYPE) # step 10-12, 5 for c in ["trends", "names"]: self.top_charts_page.verify_sorting(c, self.top_charts_page.APPLE_TYPE) self.top_charts_page.verify_sorting("positions", self.top_charts_page.APPLE_TYPE) # step 14 names_before = self.top_charts_page.get_track_names() self.top_charts_page.change_apple_market(AppConfig.get("market")["australia"]["name"]) names_after = self.top_charts_page.get_track_names() self.ts.markFinal( names_before != names_after, "STEP 14: table data is changes after new owner " "market is chosen:\n before: {},\n after: {} ".format(names_before, names_after), ) # NOT AUTOMATED STEPS - 6-7