import allure import pytest from assertpy import assert_that from src.helpers.csv_utils import read_csv @pytest.mark.usefixtures("app") class TestTrackPageTiktokExport: eu_list = {'MT', 'NO', 'SE', 'MK', 'BE', 'LU', 'IE', 'FI', 'TR', 'LT', 'CY', 'NL', 'HR', 'CZ', 'LI', 'SI', 'DE', 'ME', 'XK', 'DK', 'AD', 'AT', 'BA', 'EE', 'RO', 'SK', 'IT', 'BG', 'LV', 'FR', 'HU', 'PL', 'MC', 'CH', 'GR', 'RS', 'IS', 'AL'} so_list = {'AR', 'AT', 'AU', 'BE', 'BR', 'CH', 'CL', 'CO', 'CR', 'CZ', 'DE', 'DK', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PT', 'RU', 'SE', 'TR', 'US', 'UY', 'ZA'} @allure.title("[AP-6518][Track> Performance> TikTok] Export verification.") @allure.description("""TC Verifies: Export on the new TikTok tab""") @allure.testcase("https://data-analytics.atlassian.net/browse/AP-6673") def test_track_page_performance_tiktok_export_csv(self): self.login_page.login() self.app.go_to(self.track_page_header.url.format("spotify", "4LRPiXqCikLlN15c3yImP7", "14")) track_title = self.track_page_header.track_title.get_text() # steps 4-5 self.track_page_header.tiktok_tab.click() self.track_page_header.tiktok_tab.is_selected() self.track_page_header.day_picker.select_days_month_year("December 2022") self.tp_tiktok_tab.choose_markets(["All Markets"]) csv_tiktok_all = self.tp_tiktok_tab.download_csv() assert_that(csv_tiktok_all.suggested_filename).is_equal_to(f"{track_title} - All markets - TikTok.csv") # step 6 csv_all = read_csv(csv_tiktok_all.suggested_filename) assert_that(list(csv_all.columns)).is_equal_to(['Date', 'Country', 'Total creations', 'UGC creations', 'PGC creations', 'Total views', 'UGC views', 'PGC views']) # steps 7-8 assert_that(csv_all['Date']).is_sorted() # step 9 assert_that(set(csv_all["Country"])).is_equal_to({"All markets"}) # step 10 creations_total = int(self.tp_tiktok_tab.legend_values.get_texts_from_list()[0].replace(",", "")) assert_that(creations_total).is_equal_to(sum(csv_all['Total creations'])) # step 11 self.tp_tiktok_tab.choose_markets(["United States"]) csv_tiktok_us = self.tp_tiktok_tab.download_csv() assert_that(csv_tiktok_us.suggested_filename).is_equal_to(f"{track_title} - US - TikTok.csv") # step 12 csv_us = read_csv(csv_tiktok_us.suggested_filename) assert_that(set(csv_us["Country"])).is_equal_to({"US"}) # step 13 self.tp_tiktok_tab.choose_region("North America") csv_tiktok_na = self.tp_tiktok_tab.download_csv() assert_that(csv_tiktok_na.suggested_filename).is_equal_to(f"{track_title} - 2 markets - TikTok.csv") # step 14 csv_na = read_csv(csv_tiktok_na.suggested_filename) assert_that(set(csv_na["Country"])).is_equal_to({"North America"}) # step 15 self.tp_tiktok_tab.choose_markets(["Albania", "Argentina", "Armenia"]) csv_tiktok_3 = self.tp_tiktok_tab.download_csv() assert_that(csv_tiktok_3.suggested_filename).is_equal_to(f"{track_title} - 3 markets - TikTok.csv") csv_3 = read_csv(csv_tiktok_3.suggested_filename) assert_that(set(csv_3["Country"])).is_equal_to({'AL, AM, AR'}) # step 16 self.app.go_to(self.track_page_header.url.format("spotify", "2FHdkquBesDIZZ0IcVYaFc", "14")) self.track_page_header.tiktok_tab.click() self.track_page_header.tiktok_tab.is_selected() self.track_page_header.day_picker.select_days_month_year("August 2022") self.tp_tiktok_tab.choose_markets(["Iraq"]) csv_tiktok_16 = self.tp_tiktok_tab.download_csv() csv_16 = read_csv(csv_tiktok_16.suggested_filename) assert_that(list(str(i) for i in csv_16["UGC creations"])).contains("nan") # already covered - steps 1-3