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.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.api_client = ApiClient() @allure.story("AP-2485") @allure.severity(allure.severity_level.NORMAL) @allure.title("Displaying of Top 200 Spotify Weekly Chart") @allure.description( """TC verifies that the data displayed in Top 200 Spotify Weekly Chart view is correct and match data on Spotify Chart https://spotifycharts.com/regional/us/weekly/latest""" ) def test_top_spotify_weekly_charts(self): self.loginPage.login_with_worker() self.topChartsPage.open_top_chart_page() self.topChartsPage.select_market(self.us["name"]) self.topChartsPage.switch_tab(self.topChartsPage.SPOTIFY_TYPE) self.topChartsPage.change_sub_tab(self.topChartsPage.WEEKLY) # step 1 self.topChartsPage.verify_elements(self.topChartsPage.SPOTIFY_TYPE) # step 2-5 table_ui = self.topChartsPage.get_all_from_table()[1] 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.WEEKLY) self.topChartsPage.compare_ui_with_api_spotify(table_ui=table_ui, table_api=spotify_api) self.topChartsPage.open_spotify_chart_for_date_dd("12/12/19") # step 9 self.topChartsPage.click_on_track_and_verify() self.trackPage.go_back() self.topChartsPage.change_sub_tab(self.topChartsPage.WEEKLY) # step 10 self.topChartsPage.click_on_artist_and_verify() self.trackPage.go_back() self.topChartsPage.change_sub_tab(self.topChartsPage.WEEKLY) # step 11-14 for c in ["positions", "trends", "names", "streams"]: self.topChartsPage.verify_sorting(column=c, dsp=self.topChartsPage.SPOTIFY_TYPE) # NOT AUTOMATED STEPS 6-8