import unittest import allure import pytest from ui_automation_framework.core import TestStatus 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 = "Germany" FIRST_DATE = "01/30/20" FIRST_TRACK_ID = "0qvj1agKVT4XzZebhN3IPt" FIRST_TRACK_POSITION = 183 SECOND_TRACK_ID = "1bcd9ur41pHd2ZXSTo31Jw" SECOND_DATE = "01/31/20" SECOND_TRACK_POSITION = 140 TRACK_TREND = 43 @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.topChartsPage = TopChartsPage(self.driver) self.trackPage = TrackPage(self.driver) self.ts = TestStatus(self.driver) @allure.story("AP-2519") @allure.severity(allure.severity_level.NORMAL) @allure.title("Trend position calculation of the track with different IDs in Spotify Daily Chart (ISRC remains the same)") @allure.description( """TC verifies the correctness of calculation trend position for the track that is present in Top Spotify Daily Chart at least two days in a row with the same ISRC but different ID numbers. Such tracks shouldn’t be considered as new ones or re-entry even though, the track ID is changed.""" ) def test_spotify_trend_with_diff_ids(self): 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 a day self.topChartsPage.open_spotify_chart_for_date(self.FIRST_DATE) is_table_empty = self.topChartsPage.table_is_empty() self.ts.markFinal(not is_table_empty, "Step 1.1: Succesfully switched the Spotify {}".format(self.FIRST_DATE)) # check that track have correct ids and trend first_track = self.topChartsPage.get_track_at_position(self.FIRST_TRACK_POSITION) self.ts.markFinal(self.FIRST_TRACK_ID.lower() in first_track["link"].lower(), "Step 2.1: Correct Track ID on position") self.ts.markFinal(first_track["trendType"] == self.topChartsPage.DOWN, "Step 2.2: Track trend is not Entry/Exit") # swtiching to previous day self.topChartsPage.open_spotify_chart_for_date(self.SECOND_DATE) is_table_empty = self.topChartsPage.table_is_empty() self.ts.markFinal(not is_table_empty, "Step 3.1: Succesfully switched the Spotify {}".format(self.SECOND_DATE)) # check that for previous day track still there second_track = self.topChartsPage.get_track_at_position(self.SECOND_TRACK_POSITION) self.ts.markFinal(self.SECOND_TRACK_ID.lower() in second_track["link"].lower(), "Step 3.2: Correct Track ID") self.ts.markFinal(second_track["trendType"] == self.topChartsPage.UP_MORE_5, "Step 3.3: Track trend is not Entry/Exit") self.ts.markFinal(True, "2 {} - 1 {} , trned {}".format(second_track["position"], first_track["position"], self.TRACK_TREND)) # check Trend value is correct self.ts.markFinal( (first_track["position"] - second_track["position"]) == self.TRACK_TREND and self.TRACK_TREND == int(second_track["trendValue"]), "Step 4: Track trend on UI {} is equal to expected {}".format(second_track["trendValue"], self.TRACK_TREND), )