import logging import unittest import allure import pytest from assertpy import assert_that from ui_automation_framework.utils import logger as cl from app.src.helpers.api_data_provider import ApiDataProvider from app.src.helpers.data_formaters import DataFormatter from app.src.helpers.waiting_wrapper import wait from app.src.pages.login_page import LoginPage from app.src.pages.profile_page import ProfilePage from app.src.pages.search_page import SearchPage from app.src.pages.streams_by_markets_page import StreamsByMarketsPage from app.src.pages.track_page import TrackPage @pytest.mark.usefixtures("set_up", "one_time_set_up", "authorized_api") class StreamsByMarketTest(unittest.TestCase): log = cl.Logger(logging.DEBUG) @pytest.fixture(autouse=True) def classSetup(self, authorized_api): self.api = authorized_api self.loginPage = LoginPage(self.driver, authorized_api) self.trackPage = TrackPage(self.driver, authorized_api) self.searchPage = SearchPage(self.driver, authorized_api) self.profilePage = ProfilePage(self.driver) self.streamsPage = StreamsByMarketsPage(self.driver, authorized_api) self.data_provider = ApiDataProvider(authorized_api) @allure.story("AG-6464") @allure.severity(allure.severity_level.NORMAL) @allure.title("Top 5 Markets 'Show All' button") @allure.description("User should be able to open top 5 markets page once streams info is available") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5519" "https://data-analytics.atlassian.net/browse/AG-5520" "https://data-analytics.atlassian.net/browse/AG-5521") @pytest.mark.smoke def test_show_all_button(self): track_with_streams = "Dance Monkey" track_without_streams = "The KKK Took" self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams) self.streamsPage.click_back_button().click_back_button() self.searchPage.clear_search_field().search_for(track_without_streams).open_track_page_from_results(1) assert_that(self.trackPage.is_top_5_show_all_not_displayed(), "Show all button is NOT displayed").is_true() @allure.story("AG-6464") @allure.severity(allure.severity_level.NORMAL) @allure.title("Streams by market content") @allure.description("Verifying all required components are available on the page") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5524" "https://data-analytics.atlassian.net/browse/AG-5525" "https://data-analytics.atlassian.net/browse/AG-5561" "https://data-analytics.atlassian.net/browse/AG-5556") @pytest.mark.smoke def test_page_content(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() track_with_no_streams_period = "everythong i wanted billie" self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) assert_that(self.streamsPage.is_date_range_picker_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_top_5_tab_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_all_markets_tab_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_combined_streams_graph_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_markets_section_displayed(), "Required section is displayed").is_true() self.streamsPage.click_back_button().click_back_button() self.searchPage.clear_search_field().search_for(track_with_no_streams_period).open_track_page_from_results(1) self.trackPage.click_top_5_show_all() assert_that(self.streamsPage.is_no_streams_in_period_displayed(), "No streams in period message is displayed").is_true() @allure.story("AG-6464") @allure.severity(allure.severity_level.NORMAL) @allure.title("Top 5 markets section") @allure.description("Top markets cards should be displayed and sorted accordingly to the number of streams") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5535" "https://data-analytics.atlassian.net/browse/AG-5536" "https://data-analytics.atlassian.net/browse/AG-5537" "https://data-analytics.atlassian.net/browse/AG-5550" "https://data-analytics.atlassian.net/browse/AG-5552") @pytest.mark.smoke def test_top_5_markets(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) self.streamsPage.scroll_down() assert_that(self.streamsPage.is_5_markets_available(), "Verifying top 5 markets present in the section").is_true() assert_that(self.streamsPage.is_top_markets_sorted(), "Verified top countries sorted").is_true() market_name = self.streamsPage.get_top_markets_data()[0][0] all_markets = self.api.apollo.get_markets()["body"] market_ui = "" for m in all_markets: if m["name"] == market_name: market_ui = m["code"].upper() self.streamsPage.click_top_market(1) assert_that(self.trackPage.is_market_changed(market_ui), "Verified appropriate market selected on market detailed page").is_true() self.trackPage.click_back_button() assert_that(self.streamsPage.is_streams_by_markets_opened(), "Streams by market page is opened").is_true() @allure.story("AG-6464") @allure.severity(allure.severity_level.NORMAL) @allure.title("Date picker") @allure.description("User should be able to change date range for streams") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5551") @pytest.mark.smoke def test_streams_by_market_date_picker_top_5(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) self.streamsPage.open_date_picker() assert_that(self.streamsPage.is_date_picker_opened(), "Verified date picker popup is opened").is_true() picker_dates = self.streamsPage.get_date_picker_dates() self.streamsPage.select_1_year_date_filter() assert_that(self.streamsPage.is_1_year_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_4_weeks_date_filter() assert_that(self.streamsPage.is_4_weeks_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_8_weeks_date_filter() assert_that(self.streamsPage.is_8_weeks_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_12_weeks_date_filter() assert_that(self.streamsPage.is_12_weeks_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_26_weeks_date_filter() assert_that(self.streamsPage.is_26_weeks_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_2_weeks_date_filter() assert_that(self.streamsPage.is_2_weeks_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() @allure.severity(allure.severity_level.NORMAL) @allure.title("Dates after navigating to the detailed market screen") @allure.description("If user changes dates on detailed market screen original date range should be saved on " "streams by market screen") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5553") @pytest.mark.smoke def test_streams_by_market_date_picker_keeping_dates(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_1_year_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) self.streamsPage.open_date_picker() assert_that(self.streamsPage.is_date_picker_opened(), "Verified date picker popup is opened").is_true() picker_dates = self.streamsPage.get_date_picker_dates() self.streamsPage.select_1_year_date_filter() assert_that(self.streamsPage.is_1_year_date_filter_applied_top_markets(picker_dates), "Verified filter applied").is_true() self.streamsPage.click_top_market(1) assert_that(self.trackPage.is_1_year_date_filter_applied(picker_dates), "Verified 1 year filter still applied").is_true() self.trackPage.open_date_picker() assert_that(self.trackPage.is_date_picker_opened(), "Verified date picker popup is opened").is_true() self.trackPage.select_2_weeks_date_filter().click_back_button() assert_that(self.streamsPage.is_1_year_date_filter_applied_top_markets(picker_dates), "Verified 1 year filter still applied").is_true() @allure.severity(allure.severity_level.NORMAL) @allure.title("Graph detailed") @allure.description("User should be able to open detailed view for combined graph in landscape mode") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5611" "https://data-analytics.atlassian.net/browse/AG-5626" "https://data-analytics.atlassian.net/browse/AG-5619" "https://data-analytics.atlassian.net/browse/AG-5618") @pytest.mark.smoke def test_combined_streams_graph_detailed(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) top_markets = self.streamsPage.get_top_markets_data()[0] self.streamsPage.open_combined_graph_detailed() assert_that(self.streamsPage.is_detailed_combined_graph_opened(), "Verified detailed view is opened").is_true() assert_that( self.streamsPage.are_top_markets_in_graph_legend(top_markets), "Verified graph legend contains top markets", ).is_true() self.streamsPage.tap_graph_for_detailed_info() assert_that(self.streamsPage.is_detailed_info_displayed(), "Verifyed detailed info is displayed").is_true() self.streamsPage.close_combined_graph_detailed() assert_that(self.streamsPage.is_detailed_combined_graph_closed(), "Verified detailed view is opened").is_true() @allure.severity(allure.severity_level.NORMAL) @allure.title("All markets tab") @allure.description("User should be able to open 'All markets' tab") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5578" "https://data-analytics.atlassian.net/browse/AG-5582" "https://data-analytics.atlassian.net/browse/AG-5583" "https://data-analytics.atlassian.net/browse/AG-5587" "https://data-analytics.atlassian.net/browse/AG-5600") @pytest.mark.smoke def test_streams_by_market_general_tab(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) self.streamsPage.open_all_markets_tab() assert_that(self.streamsPage.is_date_range_picker_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_top_5_tab_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_all_markets_tab_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_markets_section_displayed(), "Required section is displayed").is_true() assert_that(self.streamsPage.is_search_field_displayed(), "Search field is displayed").is_true() assert_that(self.streamsPage.is_all_markets_sorted(), "Countries are sorted").is_true() markets = self.streamsPage.get_markets_data()[0] all_markets = self.api.apollo.get_markets()["body"] market_ui = "" for m in all_markets: if m["name"] == markets[0]: market_ui = m["code"].upper() break self.streamsPage.click_all_markets_card() assert_that(self.trackPage.is_market_changed(market_ui), "Verified appropriate market selected on market detailed page").is_true() self.trackPage.click_back_button() assert_that(self.streamsPage.is_streams_by_markets_opened(), "Streams by market page is opened").is_true() self.streamsPage.scroll_down().scroll_down() assert_that(self.streamsPage.is_markets_list_scrolled(), "Markets list is scrolled").is_true() @allure.story("AG-6465") @allure.severity(allure.severity_level.NORMAL) @allure.title("Date picker") @allure.description("User should be able to change date range for streams") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5589") @pytest.mark.smoke def test_streams_by_market_date_picker_general(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_1_year_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) self.streamsPage.open_all_markets_tab().open_date_picker() assert_that(self.streamsPage.is_date_picker_opened(), "Verified date picker popup is opened").is_true() picker_dates = self.streamsPage.get_date_picker_dates() self.streamsPage.select_1_year_date_filter() assert_that(self.streamsPage.is_1_year_date_filter_applied(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_4_weeks_date_filter() assert_that(self.streamsPage.is_4_weeks_date_filter_applied(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_8_weeks_date_filter() assert_that(self.streamsPage.is_8_weeks_date_filter_applied(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_12_weeks_date_filter() assert_that(self.streamsPage.is_12_weeks_date_filter_applied(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_26_weeks_date_filter() assert_that(self.streamsPage.is_26_weeks_date_filter_applied(picker_dates), "Verified filter applied").is_true() self.streamsPage.open_date_picker().select_2_weeks_date_filter() assert_that(self.streamsPage.is_2_weeks_date_filter_applied(picker_dates), "Verified filter applied").is_true() @allure.story("AG-6465") @allure.severity(allure.severity_level.NORMAL) @allure.title("Search market") @allure.description("User should be able to search for market") @allure.testcase( "https://data-analytics.atlassian.net/browse/AG-5591" "https://data-analytics.atlassian.net/browse/AG-5592" "https://data-analytics.atlassian.net/browse/AG-5593" "https://data-analytics.atlassian.net/browse/AG-5594" "https://data-analytics.atlassian.net/browse/AG-5595" "https://data-analytics.atlassian.net/browse/AG-5596" ) @pytest.mark.smoke def test_streams_by_market_search(self): track_with_streams = "As it was" query_1 = "United States" query_2 = "Germany" query_3 = "Z" query_4 = "A" self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams) self.streamsPage.open_all_markets_tab().search_for_market(query_1) assert_that(self.streamsPage.is_market_filtered(query_1, query_2), "Search results accordingly to query").is_true() self.streamsPage.clear_search_field() assert_that(self.streamsPage.are_all_markets_displayed(query_1, query_2), "Search query is cleared").is_true() self.streamsPage.search_for_market(query_3) assert_that(self.streamsPage.is_market_filtered(query_3, query_1), "Search results accordingly to query").is_true() self.streamsPage.clear_search_field().search_for_market(query_4).scroll_down().scroll_down() assert_that(self.streamsPage.is_markets_list_scrolled(), "Markets list is scrolled").is_true() @allure.story("AG-6465") @allure.severity(allure.severity_level.NORMAL) @allure.title("i-icons popups") @allure.description("User should be able to open info popups") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5645" "https://data-analytics.atlassian.net/browse/AG-5647" "https://data-analytics.atlassian.net/browse/AG-5649" "https://data-analytics.atlassian.net/browse/AG-5650") @pytest.mark.smoke def test_streams_by_i_icons(self): track_with_streams = self.data_provider.get_top_charts_spotify_track_data() self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(track_with_streams[0]) markets = self.streamsPage.get_top_markets_data()[0] date_picker_dates = self.streamsPage.get_selected_dates() self.streamsPage.open_combined_graph_i_popup() assert_that(self.streamsPage.is_combined_graph_popup_opened(), "Verified graph popup is opened").is_true() assert_that(self.streamsPage.are_top_markets_in_popup(markets), "Verified top markets info are in popup").is_true() assert_that(self.streamsPage.are_selected_dates_in_popup(date_picker_dates), "Verified selected dates are in popup").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-7447") @allure.severity(allure.severity_level.NORMAL) @allure.title("Top 5 markets API/UI integration") @allure.description("API and UI data for the top 5 markets should match") @pytest.mark.smoke def test_top5_data_api_integration(self): days_period = 13 test_data = self.data_provider.get_top_charts_spotify_track_data() test_track_name = test_data[0] test_track_isrc = test_data[1] dates = self.data_provider.get_track_start_end_dates(test_track_isrc, days_period) top_5_api_data = self.api.dsp.get_analytics_v1_track_markets_list(f"start_date={dates[0]}", f"end_date={dates[1]}", f"isrc={test_track_isrc}", "limit=5")["body"]["markets"] market_names = self.api.apollo.get_markets()["body"] self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(test_track_name) top_5_ui_data = self.streamsPage.get_top_markets_data() api_markets = [] trends = [] for market in top_5_api_data: api_markets.append(market["market"]) calculated_trend = round(((market["current_streams"] - market["prev_streams"]) / market["prev_streams"]) * 100) trends.append(calculated_trend) assert_that(top_5_ui_data[2]).described_as("Streams numbers").contains(DataFormatter.round_streams_demographics(market["current_streams"])) assert_that( any(DataFormatter.format_api_to_ui_dates(market["start_date"]) in date for date in top_5_ui_data[1]), f"Data not found: {DataFormatter.format_api_to_ui_dates(market['start_date'])} in {top_5_ui_data[1]}", ).is_true() assert_that( any(DataFormatter.format_api_to_ui_dates(market["end_date"]) in date for date in top_5_ui_data[1]), f"Data not found: {DataFormatter.format_api_to_ui_dates(market['end_date'])} in {top_5_ui_data[1]}", ).is_true() for api_name in api_markets: for name in market_names: if name["code"] == api_name: assert_that(top_5_ui_data[0], "Market is found").contains(name["name"]) for i in range(len(trends)): if trends[i] > 0: icon = "\ue905" elif trends[i] < 0: icon = "\ue902" else: icon = "\ue904" assert_that(top_5_ui_data[3][i], "Trends icon").contains(icon) for i in range(len(trends)): assert_that(top_5_ui_data[4][i], "Trend Value").contains(str(abs(trends[i]))) @allure.story("https://data-analytics.atlassian.net/browse/AG-7447") @allure.severity(allure.severity_level.NORMAL) @allure.title("All markets API/UI integration") @allure.description("API and UI data for All markets should match") @pytest.mark.smoke def test_all_markets_data_api_integration(self): days_period = 13 test_data = self.data_provider.get_top_charts_spotify_track_data() test_track_name = test_data[0] test_track_isrc = test_data[1] dates = self.data_provider.get_track_start_end_dates(test_track_isrc, days_period) markets_api_data = self.api.dsp.get_analytics_v1_track_markets_list(f"start_date={dates[0]}", f"end_date={dates[1]}", f"isrc={test_track_isrc}", "limit=20")["body"]["markets"] market_names = self.api.apollo.get_markets()["body"] self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(test_track_name) top_5_ui_data = self.streamsPage.open_all_markets_tab().get_markets_data() api_markets = [] trends = [] for market in markets_api_data: api_markets.append(market["market"]) calculated_trend = round(((market["current_streams"] - market["prev_streams"]) / market["prev_streams"]) * 100) trends.append(calculated_trend) assert_that(top_5_ui_data[2], "Streams number").contains(DataFormatter.round_streams_demographics(market["current_streams"])) assert_that( any(DataFormatter.format_api_to_ui_dates(market["start_date"]) in date for date in top_5_ui_data[1]), f"Data not found: {DataFormatter.format_api_to_ui_dates(market['start_date'])} in {top_5_ui_data[1]}", ).is_true() assert_that( any(DataFormatter.format_api_to_ui_dates(market["end_date"]) in date for date in top_5_ui_data[1]), f"Data not found: {DataFormatter.format_api_to_ui_dates(market['end_date'])} in {top_5_ui_data[1]}", ).is_true() for api_name in api_markets: for name in market_names: if name["code"] == api_name: assert name["name"] in top_5_ui_data[0], "Market wasn't found" for i in range(len(trends)): assert_that(top_5_ui_data[4][i], "Trend for country").contains(str(abs(trends[i]))) for i in range(len(trends)): if trends[i] > 0: icon = "\ue905" elif trends[i] < 0: icon = "\ue902" else: icon = "\ue904" assert_that(top_5_ui_data[3][i], "Trend icon").contains(icon) def search_open_and_go_to_the_top_markets_screen(self, track_name, position=1): self.profilePage.select_search_tab() self.searchPage.search_for(track_name).open_track_page_from_results(position) self.trackPage.click_top_5_show_all() assert_that(self.streamsPage.is_streams_by_markets_opened(), "Show all button is displayed").is_true() @allure.story("https://data-analytics.atlassian.net/browse/AG-7017") @allure.severity(allure.severity_level.NORMAL) @allure.title("Analyzing the default and detailed graphs") @allure.description("Analyzing the data and format of detailed and default graphs") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5574" "https://data-analytics.atlassian.net/browse/AG-5613" "https://data-analytics.atlassian.net/browse/AG-5577" "https://data-analytics.atlassian.net/browse/AG-5616") @pytest.mark.regression def test_data_on_default_and_detailed_streams_graph(self): days_period = 13 test_data = self.data_provider.get_top_charts_spotify_track_data() test_track_name = test_data[0] test_track_isrc = test_data[1] dates = self.data_provider.get_track_start_end_dates(test_track_isrc, days_period) top_5_api_data = self.api.dsp.get_analytics_v1_track_markets_list(f"start_date={dates[0]}", f"end_date={dates[1]}", f"isrc={test_track_isrc}", "limit=5")["body"]["markets"] list_markets = [i["market"] for i in top_5_api_data if i["market"]] dict_data = {} for item in list_markets: detailed_streams_global = self.api.dsp.get_dsp_api_streams_graph( f"isrc={test_track_isrc}", f"start_date={dates[0]}", f"end_date={dates[1]}", f"market={item}", "per_vendors=false", )["body"] list_data = [i["y"] for i in detailed_streams_global["coordinates"] if i["y"]] dict_data.update({item: list_data}) sum_all = [max(column) for column in zip(*dict_data.values())] max_y_plot = max(sum_all) + 0.05 * max(sum_all) max_y_plot_str_default = str(DataFormatter.round_streams(max_y_plot)) self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(test_track_name) market_card_data_default_combined = self.streamsPage.get_market_default_card_data() assert_that(market_card_data_default_combined, "Total streams value on Y-axis for five top markets").contains(max_y_plot_str_default) self.streamsPage.open_combined_graph_detailed() assert_that(self.streamsPage.is_detailed_combined_graph_opened(), "Verified detailed view is opened").is_true() self.trackPage.tap_beginning_of_the_graph() market_card_data_detailed_combined = self.streamsPage.get_market_detailed_card_data() assert_that(market_card_data_detailed_combined, "Total streams value on Y-axis for five top markets").contains(max_y_plot_str_default) dict_keys = [] for items in dict_data.keys(): dict_keys.append(items) assert_that(market_card_data_detailed_combined, "Stream value for a given market from top five markets").contains(str(DataFormatter.round_streams(dict_data[dict_keys[0]][0]))).contains(str(DataFormatter.round_streams(dict_data[dict_keys[1]][0]))).contains( str(DataFormatter.round_streams(dict_data[dict_keys[2]][0])) ).contains(str(DataFormatter.round_streams(dict_data[dict_keys[3]][0]))).contains(str(DataFormatter.round_streams(dict_data[dict_keys[4]][0]))) @allure.story("https://data-analytics.atlassian.net/browse/AG-7017") @allure.severity(allure.severity_level.NORMAL) @allure.title("Analyzing the case with a few top markets") @allure.description("Analyzing the data with few available streams statistics for a given track") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5573") @pytest.mark.regression def test_data_with_few_streams(self): days_period = 365 test_track_name = "drivers license" test_track_isrc = "USUG12004749" dates = self.data_provider.get_track_start_end_dates(test_track_isrc, days_period) top_5_api_data = self.api.dsp.get_analytics_v1_track_markets_list(f"start_date={dates[0]}", f"end_date={dates[1]}", f"isrc={test_track_isrc}", "limit=5")["body"]["markets"] list_markets = [i["market"] for i in top_5_api_data if i["market"]] dict_data = {} for item in list_markets: detailed_streams_global = self.api.dsp.get_dsp_api_streams_graph( f"isrc={test_track_isrc}", f"start_date={dates[0]}", f"end_date={dates[1]}", f"market={item}", "per_vendors=false", )["body"] list_data = [i["y"] for i in detailed_streams_global["coordinates"] if i["y"]] dict_data.update({item: list_data}) dict_data = {k: v for k, v in dict_data.items() if v != []} assert_that(dict_data, "The number of markets").is_length(1) position = next( filter( lambda x: x[1]["external_ids"]["isrc"] == test_track_isrc, enumerate(self.api.apollo.get_list_of_spotify_tracks(test_track_name)["body"]["tracks"]["items"], 1), ) )[0] self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(test_track_name, position) self.streamsPage.open_date_picker().select_1_year_date_filter() wait(lambda: self.streamsPage.lt_top_5_markets.elements) wait(lambda: len(self.streamsPage.lt_top_5_markets.elements) == 1) @allure.story("AG-7018") @allure.severity(allure.severity_level.NORMAL) @allure.title("Search wrong market") @allure.description("User should be able to search for wrong market with an appropriate response") @allure.testcase("https://data-analytics.atlassian.net/browse/AG-5599" "https://data-analytics.atlassian.net/browse/AG-5597") @pytest.mark.regression def test_streams_by_wrong_market_search(self): test_data = self.data_provider.get_top_charts_spotify_track_data() test_track_name = test_data[0] query_1 = "ddfddddfdfdfdfdddfdfdfdfdfdsdsdsdsdsfdfdfdfdfdddfdf" self.loginPage.login_as_regular_user() self.search_open_and_go_to_the_top_markets_screen(test_track_name) self.streamsPage.open_all_markets_tab().search_for_market(query_1) assert_that(self.streamsPage.is_market_section_available_without_correct_data(), "Market does not exist").is_true()