import allure import pytest from allure_commons._allure import step from src.data.amplitude_data import TRACK_PAGE @pytest.mark.usefixtures("app") class TestTrackPagePerformanceGraphExportPNGEvents: by_markets_tab_name = "by Markets" youtube_tab_name = "YouTube" tiktok_tab_name = "TikTok" @pytest.mark.parametrize("dsp,id", [ ("spotify", "4jPy3l0RUwlUI9T5XHBW2m"), ("apple", "1668892944"), ]) @allure.title("[AP-10796][Track Page][Graph> Export as PNG] Amplitude event verification. SAS tab") @allure.description("TC Verifies: Export event in Amplitude. SAS tab") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-10858") @pytest.mark.regression def test_track_page_performance_export_png_events_sas_tab(self, dsp, id): self.login_page.login() # step 1 self.app.go_to(self.track_page_header.url.format(dsp, id, "14")) self.track_page_header.sas_tab.is_selected() self.verify_export_png_event("Spotify", "By Source") # step 2 self.verify_export_png_event("Spotify", "All Streams") self.verify_export_png_event("Spotify", "Lean Fwd / Back") self.verify_export_png_event("Apple Music", "By Source") self.verify_export_png_event("Apple Music", "All Streams") self.verify_export_png_event("Apple Music", "Lean Fwd / Back") self.verify_export_png_event("Amazon", "By Source") self.verify_export_png_event("Amazon", "All Streams") self.verify_export_png_event("Amazon", "Lean Fwd / Back") self.verify_export_png_event("Amazon", "By Voice") self.verify_export_png_event("Amazon", "By Tier") self.verify_export_png_event("By DSP") self.verify_export_png_event("All Streams") @pytest.mark.parametrize("dsp,id", [ ("spotify", "4jPy3l0RUwlUI9T5XHBW2m"), ("apple", "1668892944"), ]) @allure.title("[AP-10796][Track Page][Graph> Export as PNG] Amplitude event verification. By Markets tab") @allure.description("TC Verifies: Export event in Amplitude. By Markets tab") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-10858") @pytest.mark.regression def test_track_page_performance_export_png_events_by_markets_tab(self, dsp, id): self.login_page.login() self.app.go_to(self.track_page_header.url.format(dsp, id, "14")) # step 3 self.track_page_header.by_markets_tab.click() self.track_page_header.by_markets_tab.is_selected() self.verify_export_png_event(dsp="All Streams", tab=self.by_markets_tab_name) # step 4 self.verify_export_png_event(dsp="Spotify", tab=self.by_markets_tab_name) self.verify_export_png_event(dsp="Apple Music", tab=self.by_markets_tab_name) self.verify_export_png_event(dsp="Amazon", tab=self.by_markets_tab_name) self.verify_export_png_event(dsp="TikTok", tab=self.by_markets_tab_name) @pytest.mark.parametrize("dsp,id", [ ("spotify", "4jPy3l0RUwlUI9T5XHBW2m"), ("apple", "1668892944"), ]) @allure.title("[AP-10796][Track Page][Graph> Export as PNG] Amplitude event verification. Youtube tab") @allure.description("TC Verifies: Export event in Amplitude. Youtube tab") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-10858") @pytest.mark.regression def test_track_page_performance_export_png_events_youtube_tab(self, dsp, id): self.login_page.login() self.app.go_to(self.track_page_header.url.format(dsp, id, "14")) # step 5 self.track_page_header.youtube_tab.click() self.track_page_header.youtube_tab.is_selected() self.verify_export_png_event(by_source="By Source", tab=self.youtube_tab_name) # step 6 self.verify_export_png_event(by_source="All Views", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="By Video", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="Lean Fwd / Back", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="By Likes", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="By Dislikes", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="By Comments", tab=self.youtube_tab_name) self.verify_export_png_event(by_source="By Shares", tab=self.youtube_tab_name) @pytest.mark.parametrize("dsp,id", [ ("spotify", "4jPy3l0RUwlUI9T5XHBW2m"), ("apple", "1668892944"), ]) @allure.title("[AP-10796][Track Page][Graph> Export as PNG] Amplitude event verification. Tiktok tab") @allure.description("TC Verifies: Export event in Amplitude. Tiktok tab") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-10858") @pytest.mark.regression def test_track_page_performance_export_png_events_tiktok_tab(self, dsp, id): self.login_page.login() self.app.go_to(self.track_page_header.url.format(dsp, id, "14")) # step 7 self.track_page_header.tiktok_tab.click() self.track_page_header.tiktok_tab.is_selected() self.verify_export_png_event_tiktok(metric="By Creations", content="All Contents") self.verify_export_png_event_tiktok(metric="By Creations", content="By UGC/PGC") self.verify_export_png_event_tiktok(metric="By Views", content="All Contents") self.verify_export_png_event_tiktok(metric="By Views", content="By UGC/PGC") @step("Verify export png amplitude event for {tab} - {dsp} {by_source}") def verify_export_png_event(self, dsp="", by_source="", tab="Streams and Sources"): payload = self.app.get_amplitude_requests() if tab == self.by_markets_tab_name: tab_ui = self.tp_by_markets_tab elif tab == self.youtube_tab_name: tab_ui = self.tp_youtube_tab else: tab_ui = self.tp_sas_tab if dsp != "": tab_ui.choose_dsp(dsp) if by_source != "": tab_ui.choose_by_source(by_source) tab_ui.download_png() self.app.verify_amplitude_events(payloads=payload, event_type=TRACK_PAGE["event_type"], event_properties={"tp_export_png": tab}) @step("Verify export png amplitude event for Tiktok - {metric} {content}") def verify_export_png_event_tiktok(self, metric, content): payload = self.app.get_amplitude_requests() self.tp_tiktok_tab.choose_metric(metric) self.tp_tiktok_tab.choose_content(content) self.tp_tiktok_tab.download_png() self.app.verify_amplitude_events(payloads=payload, event_type=TRACK_PAGE["event_type"], event_properties={"tp_export_png": self.tiktok_tab_name})