import unittest 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.chart_digest import ChartDigestPage from app.src.pages.left_navigation_panel import LeftNavigationPanel from app.src.pages.login_page import LoginPage 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"]["name"] @pytest.fixture(autouse=True) def classSetup(self): self.loginPage = LoginPage(self.driver) self.left_panel = LeftNavigationPanel(self.driver) self.chart_digest = ChartDigestPage(self.driver) self.trackPage = TrackPage(self.driver) self.api_client = ApiClient() self.ts = TestStatus(self.driver) @allure.story("AP-1650") @allure.severity(allure.severity_level.NORMAL) @allure.title("‘Sony’ label on Daily Charts Digest sections for Apple tracks is not displayed") @allure.description("""TC Verifies that the label ‘Sony Track’ is not shown for Apple tracks.""") def test_sony_label_for_apple_tracks(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.left_panel.open_chart_digest_page() self.chart_digest.is_opened() self.trackPage.select_market(self.us) # step 1-3 self.chart_digest.select_tab("{table}-{tab}".format(table=self.chart_digest.TOP_VIEW, tab=self.chart_digest.TAB_APPLE)) self.chart_digest.select_section_for_table("{table}-{section}".format(table=self.chart_digest.TOP_VIEW, section=self.chart_digest.SECTION_TOP_10)) tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.TOP_VIEW) api_tracks = self.api_client.get_vendor_api_tracks(vendor="apple", market=AppConfig.get("market")["us"]["market"], token=token) sony_non_sony = [api_tracks["tracks"][t]["is_sony"] for t in range(len(api_tracks["tracks"]))] for label in sony_non_sony: assert_that(label).is_equal_to(False) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 1-3: no sony tracks for apple top 10") # step 4 self.chart_digest.select_section_for_table("{table}-{section}".format(table=self.chart_digest.TOP_VIEW, section=self.chart_digest.SECTION_EXITS_TOP_10)) tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.TOP_VIEW) api_tracks = self.api_client.get_top_10_exits(vendor="apple", market=AppConfig.get("market")["us"]["api"]) if len(api_tracks) > 0: sony_non_sony = [api_tracks["tracks"][t]["is_sony"] for t in range(len(api_tracks["tracks"]))] for label in sony_non_sony: assert_that(label).is_equal_to(False) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 4: no sony tracks for apple top 10 exits") # step 5 self.chart_digest.select_tab(tab=self.chart_digest.TAB_APPLE) tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.MAJOR_MOVES) api_tracks = self.api_client.get_major_moves_tracks(vendor="apple", market=AppConfig.get("market")["us"]["api"]) sony_non_sony = [api_tracks["tracks"][t]["is_sony"] for t in range(len(api_tracks["tracks"]))] for label in sony_non_sony: assert_that(label).is_equal_to(False) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 5: no sony tracks for apple major moves") # step 6-7 tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.CHART_CHANGES) chart_date_api = self.api_client.get_vendor_api_tracks(vendor=self.chart_digest.TAB_APPLE, market=AppConfig.get("market")["us"]["market"], token=token)["chart_date"] entries_api = self.api_client.get_charts_additions(vendor=self.chart_digest.TAB_APPLE, market=AppConfig.get("market")["us"]["market"], date=chart_date_api, token=token)["tracks"] exits_api = self.api_client.get_charts_removals(vendor=self.chart_digest.TAB_APPLE, market=AppConfig.get("market")["canada"]["market"], date=chart_date_api, token=token)["tracks"] sony_non_sony_entries = [entries_api[e]["is_sony"] for e in range(len(entries_api))] sony_non_sony_exits = [exits_api[e]["is_sony"] for e in range(len(exits_api))] for label in sony_non_sony_entries: assert_that(label).is_equal_to(False) for label in sony_non_sony_exits: assert_that(label).is_equal_to(False) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 6-7: no sony tracks for apple chart changes") # step 8 self.trackPage.select_market(AppConfig.get("market")["global"]["name"]) self.chart_digest.select_tab(tab=self.chart_digest.TAB_APPLE) popup = self.chart_digest.open_chart_changes_popup() if popup: tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.CHART_CHANGES, modal=True) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 8: no sony tracks for apple chart changes popup") self.chart_digest.close_chart_changes_popup() # step 9 tracks = self.chart_digest.get_names_from_table(table=self.chart_digest.BUBBLING_UNDER) api_tracks = self.api_client.get_vendor_api_tracks(vendor="apple", market=AppConfig.get("market")["us"]["market"], token=token, end=60) sony_non_sony = [api_tracks["tracks"][t]["is_sony"] for t in range(len(api_tracks["tracks"]))] for label in sony_non_sony[50:60]: assert_that(label).is_equal_to(False) self.ts.markFinal(all("SONY" not in t for t in tracks), "STEP 9: no sony tracks for apple for bubbling under")