import unittest from datetime import datetime import allure import pytest 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.login_page import LoginPage from app.src.pages.third_party.spotifycharts_page import SpotifyCharts 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"] @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.trackPage = TrackPage(self.driver) self.comparison_page = TrackComparisonPage(self.driver) self.spotify_charts = SpotifyCharts(self.driver) self.ts = TestStatus(self.driver) self.chart_digest = ChartDigestPage(self.driver) self.api_client = ApiClient() @allure.story("AP-1413") @allure.severity(allure.severity_level.NORMAL) @allure.title("Displaying of Top 200 Spotify Daily chart") @allure.description( """TC verifies that Top 200 Spotify/Top 100 Apple charts are available for user from the Charts Digest page. This functionality provides an ability to access a full list of market-specific Spotify charts. """ ) def test_top_spotify_daily(self): self.loginPage.login_with_worker() self.loginPage.is_logged_in() self.topChartsPage.select_market(self.us["name"]) self.chart_digest.open_charts_digest_page() self.chart_digest.is_opened() # step 1-2 for b in [self.chart_digest.MAJOR_MOVES, self.chart_digest.BUBBLING_UNDER]: self.chart_digest.open_top_charts_from_table(b) self.topChartsPage.go_back() for t in [self.chart_digest.TAB_SPOTIFY, self.chart_digest.TAB_APPLE]: self.chart_digest.select_tab("{}-{}".format(self.chart_digest.TOP_VIEW, t)) for s in [self.chart_digest.SECTION_TOP_10, self.chart_digest.SECTION_EXITS_TOP_10]: self.chart_digest.select_section_for_table("{}-{}".format(self.chart_digest.TOP_VIEW, s)) self.chart_digest.open_top_charts_from_table(self.chart_digest.TOP_VIEW) self.topChartsPage.go_back() # step 3 self.topChartsPage.open_top_chart_page() self.topChartsPage.top_chart_page_is_opened() self.topChartsPage.verify_elements(self.topChartsPage.SPOTIFY_TYPE) self.topChartsPage.switch_tab(self.topChartsPage.SPOTIFY_TYPE) self.topChartsPage.change_sub_tab(self.topChartsPage.DAILY) # step 4 table_ui = self.topChartsPage.get_all_from_table()[1] # step 7 current_date_ui = self.topChartsPage.get_chosen_date() current_date_ui_f = datetime.strptime(current_date_ui, AppConfig.get("date_formats")["mm/dd/yy"]).strftime("%Y-%m-%d") spotify_api = self.api_client.get_charts_tracks(vendor="spotify", market=self.us["api"], date=current_date_ui_f, type=self.topChartsPage.DAILY) self.topChartsPage.compare_ui_with_api_spotify(table_ui=table_ui, table_api=spotify_api) # step 8 self.topChartsPage.click_on_track_and_verify() self.trackPage.go_back() self.topChartsPage.change_sub_tab(self.topChartsPage.DAILY) # step 9 self.topChartsPage.click_on_artist_and_verify() self.trackPage.go_back() self.topChartsPage.change_sub_tab(self.topChartsPage.DAILY) # step 10-13 for c in ["positions", "trends", "names", "streams"]: self.topChartsPage.verify_sorting(column=c, dsp=self.topChartsPage.SPOTIFY_TYPE) # NOT AUTOMATED - STEPS 5-6