import unittest from datetime import datetime import allure import pytest from assertpy import assert_that from ui_automation_framework.core import TestStatus from ui_automation_framework.utils import AppConfig 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): @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-1549") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verification of data stamp on Top Charts page") @allure.description( """TC verifies that the user can see the tooltip with the date for which chart data is taken. The tooltip and clock icon are displayed on the Top Charts page according to the designs.""" ) def test_clock_icon(self): user = self.loginPage.get_user_email_with_worker() token = self.api_client.authorize(user=user) self.loginPage.login_with_worker() self.topChartsPage.open_top_chart_page() # exist for Apple tab self.topChartsPage.switch_tab("apple") is_present = self.topChartsPage.clock_element_is_present() self.ts.markFinal(is_present, "Step 2: Clock exist for Apple Music tab") # compare tooltip with DB tooltip_message = self.topChartsPage.get_clock_tooplip() apple_date = self.api_client.get_vendor_api_tracks(vendor="apple", market=AppConfig.get("market")["global"]["api2"], token=token)["chart_date"] apple_date = datetime.strptime(apple_date, "%Y-%m-%d").strftime(self.trackPage.get_date_format_from_locale()) concated_apple_date = f"Apple Music data up to {apple_date}." # step 3 assert_that(tooltip_message).described_as("Step 3").is_equal_to(concated_apple_date)