# import datetime # import unittest # # import allure # import pytest # from ui_automation_framework.core import TestStatus # from ui_automation_framework.utils import AppConfig, CoreConfig # # from app.api_client import ApiClient # from app.src.pages.login_page import LoginPage # 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): # MARKET = "Japan" # TRACK_ID = "0ApuDyXWrX6CFYnqlvy0ao" # date_01_15_20 = "01/15/20" # date_01_16_20 = "01/16/20" # date_01_22_20 = "01/22/20" # # @pytest.fixture(autouse=True) # def classSetup(self): # self.loginPage = LoginPage(self.driver) # self.topChartsPage = TopChartsPage(self.driver) # self.trackPage = TrackPage(self.driver) # self.api_client = ApiClient() # self.ts = TestStatus(self.driver) # # @allure.story("AP-2670") # @allure.severity(allure.severity_level.NORMAL) # @allure.title("Spotify top chart with track without ISRC. Chart changes and position trend calculation") # @allure.description( # """TC verifies that the chart where one of the tracks is without ISRC is received in response from BE, displayed on UI, can be downloaded in .csv file. Test also verifies displaying of such tracks in entries/exits and position trend calculation.""" # ) # def test_non_spotify_isrc(self): # user = self.loginPage.get_user_email_with_worker() # token = self.api_client.authorize(user=user) # self.loginPage.login_with_worker() # self.loginPage.is_logged_in() # # self.topChartsPage.open_top_chart_page() # self.topChartsPage.top_chart_page_is_opened() # # self.topChartsPage.select_market(self.MARKET) # self.topChartsPage.switch_tab(self.topChartsPage.SPOTIFY_TYPE) # # # Open a chart for 2020-01-16 # self.topChartsPage.open_spotify_chart_for_date(self.date_01_16_20) # is_table_empty = self.topChartsPage.table_is_empty() # self.ts.markFinal(not is_table_empty, f"Step 3.1: Switched to {self.date_01_16_20} for Spotify") # self.topChartsPage.change_filter_value("Voice Comment", self.topChartsPage.SPOTIFY_TYPE) # # "position": 131 #trend = 55 down # track_present_on_position = self.topChartsPage.check_track_for_position( # self.TRACK_ID, 131, self.topChartsPage.DOWN_MORE_5, 55 # ) # check for positions # self.ts.markFinal(track_present_on_position, "Step 3.2: Track on its place") # # # Open required chart for day 2020-01-22 when the tested track was removed # self.topChartsPage.spotify_filter_click_clear_icon() # self.topChartsPage.open_spotify_chart_for_date(self.date_01_22_20) # is_table_empty = self.topChartsPage.table_is_empty() # self.ts.markFinal(not is_table_empty, "Step 4.1: Switched to 01/22/2020 for Spotify") # # self.topChartsPage.change_filter_value("Voice Comment", self.topChartsPage.SPOTIFY_TYPE) # is_table_empty = self.topChartsPage.table_is_empty() # self.ts.markFinal(is_table_empty, "Step 4.2: Track left the chart") # # # Verify Exits for 2020-01-22 (if possible check on UI section) # date_01_22_20_f = datetime.datetime.strptime(self.date_01_22_20, self.trackPage.get_date_format_from_locale()).strftime("%Y-%m-%d") # is_present_in_exists = self.topChartsPage.find_in_exists( # self.TRACK_ID, self.topChartsPage.SPOTIFY_TYPE, "jp", date_01_22_20_f # ) # self.ts.markFinal(is_present_in_exists, "Step 5: Track are in exists") # # # Open a chart for a day when track without ISRC enters # self.topChartsPage.spotify_filter_click_clear_icon() # self.topChartsPage.open_spotify_chart_for_date(self.date_01_15_20) # is_table_empty = self.topChartsPage.table_is_empty() # self.ts.markFinal(not is_table_empty, "Step 1: Succesfully switched the Spotify date") # # # check for specific track and trend # self.topChartsPage.change_filter_value("Voice Comment", self.topChartsPage.SPOTIFY_TYPE) # track_present_on_position = self.topChartsPage.check_track_for_position( # self.TRACK_ID, 76, self.topChartsPage.ENTRY # ) # check for positions # self.ts.markFinal(track_present_on_position, "Step 2.1: Track on its place") # # csv = self.topChartsPage.export_file(market=AppConfig.get("market")["jp"], token=token) # self.ts.markFinal( # "Voice Comment" == csv["Track Name"].to_list()[75], # "track is present in csv: {}".format(csv["Track Name"].to_list()[75]), # ) # self.ts.markFinal( # "King Gnu" == csv["Artist"].to_list()[75], "artist is in csv: {}".format(csv["Artist"].to_list()[75]) # ) # # # check for entries # date_01_15_20_f = datetime.datetime.strptime(self.date_01_15_20, self.trackPage.get_date_format_from_locale()).strftime("%Y-%m-%d") # is_present_in_entries = self.topChartsPage.find_in_entries( # self.TRACK_ID, self.topChartsPage.SPOTIFY_TYPE, "jp", date_01_15_20_f # ) # self.ts.markFinal(is_present_in_entries, "Step 2.3: Track are in entries for 01/15/2020") # test is no longer relevant due to Delphi logic, skip until fixes are available