import allure import pytest from assertpy import assert_that from src.helpers.test_data_loader import DataLoader from src.helpers.api_data_provider import ApiDataProvider @pytest.mark.usefixtures("one_time_set_up") class TestCountries: api_data = ApiDataProvider() artist_name = DataLoader.get_artist() country_spotify_top = 'Canada' countrycode_spotify_top = 'ca' @allure.title("Countries - base info") @allure.description("User should be able to view information per country") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1908") @pytest.mark.smoke def test_country_info(self): self.login_page.login_as_super_user() self.welcome_page.click_skip_btn() self.artist_selector_page.select_an_artist_by_position(1) self.navigation_page.click_globe_tab() assert_that(self.countries_page.is_countries_label_present(), "Countries label should be present").is_true() assert_that(self.navigation_page.get_time_interval_value()).is_equal_to("Last 4 weeks") top_country_4w = self.countries_page.list_countries.texts[0] self.navigation_page.select_period_last_1_year() assert_that(self.navigation_page.get_time_interval_value()).is_equal_to("Last 1 year") top_country_1y = self.countries_page.list_countries.texts[0] assert_that(top_country_4w).is_not_equal_to(top_country_1y) # Check country page self.countries_page.list_countries.select_by_position(1) assert_that(self.countries_page.is_track_1w_statistics_present(), "1w statistics should be shown").is_true() assert_that(self.countries_page.is_track_2w_statistics_present(), "2w statistics should be shown").is_true() assert_that(self.countries_page.is_track_4w_statistics_present(), "4w statistics should be shown").is_true() assert_that(self.countries_page.is_chart_present('ALL Streams')).is_true() assert_that(self.countries_page.is_chart_present('SPOTIFY Streams')).is_true() assert_that(self.countries_page.is_chart_present('APPLE Streams')).is_true() assert_that(self.countries_page.is_chart_present('AMAZON Streams')).is_true() assert_that(self.countries_page.is_chart_present('ALL Top Tracks')).is_true() assert_that(self.countries_page.is_chart_present('SPOTIFY Top Tracks')).is_true() assert_that(self.countries_page.is_chart_present('APPLE Top Tracks')).is_true() assert_that(self.countries_page.is_chart_present('AMAZON Top Tracks')).is_true() assert_that(self.countries_page.is_chart_present('SPOTIFY CHART Daily Top 200')).is_true() assert_that(self.countries_page.is_chart_present('APPLE CHART Top 100')).is_true() assert_that(self.countries_page.is_chart_present('SPOTIFY Demographics')).is_true() assert_that(self.countries_page.is_chart_present('APPLE Demographics')).is_true() assert_that(self.countries_page.are_demographic_elements_present_for('SPOTIFY')).is_true() assert_that(self.countries_page.are_demographic_elements_present_for('APPLE')).is_true() @allure.title("Country - Streams") @allure.description("User should be able to view Streams per country") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-2128") @pytest.mark.regression def test_country_streams(self): country = 'Australia' self.login_page.login_as_super_user() self.welcome_page.click_skip_btn() self.artist_selector_page.select_an_artist_by_name(self.artist_name) self.navigation_page.click_globe_tab() assert_that(self.countries_page.is_countries_label_present(), "Countries label should be present").is_true() self.countries_page.select_country_by_name(country) assert_that(self.countries_page.is_label_present(country)).is_true() self.countries_page.charts_list.select_by_text('ALL Streams') assert_that(self.countries_page.is_label_present("ALL ")).is_true() assert_that(self.countries_page.is_label_present(f"Streams in {country}")).is_true() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_2w() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_4w() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.select_market_by_name("The United States") assert_that(self.countries_page.chosen_market_value("us")).is_true() assert_that(self.countries_page.is_label_present("ALL ")).is_true() assert_that(self.countries_page.is_label_present("Streams in the United States")).is_true() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # SPOTIFY Streams self.countries_page.charts_list.select_by_text('SPOTIFY Streams') self.countries_page.select_market_by_name("The United States") assert_that(self.countries_page.chosen_market_value("us")).is_true() assert_that(self.countries_page.is_label_present("SPOTIFY ")).is_true() assert_that(self.countries_page.is_label_present("Streams in the United States")).is_true() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_6w() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_8w() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # APPLE Streams self.countries_page.charts_list.select_by_text('APPLE Streams') assert_that(self.countries_page.is_label_present("APPLE ")).is_true() assert_that(self.countries_page.is_label_present(f"Streams in {country}")).is_true() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_26w() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_1y() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # AMAZON Streams self.countries_page.charts_list.select_by_text('AMAZON Streams') assert_that(self.countries_page.is_label_present("AMAZON ")).is_true() assert_that(self.countries_page.is_label_present(f"Streams in {country}")).is_true() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() self.countries_page.switch_range_to_chart_week() assert_that(self.countries_page.is_stream_data_present(), "No data or Error occurred").is_true() @allure.title("Country - Daily Top") @allure.description("User should be able to view Daily Top for country") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-2130") @pytest.mark.regression def test_country_top_100_200(self): top_artist, top_track = self.api_data.get_artist_and_track_from_top_chart('spotify', self.countrycode_spotify_top) self.login_page.login_as_super_user() self.welcome_page.click_skip_btn() self.artist_selector_page.select_an_artist_by_name(top_artist) self.navigation_page.click_globe_tab() assert_that(self.countries_page.is_countries_label_present(), "Countries label should be present").is_true() self.countries_page.select_country_by_name(self.country_spotify_top) # Spotify self.countries_page.charts_list.select_by_text('SPOTIFY CHART Daily Top 200') assert_that(self.countries_page.chosen_market_value(self.countrycode_spotify_top)).is_true() assert_that(self.countries_page.is_label_present(top_artist)).is_true() assert_that(self.countries_page.is_label_present("SPOTIFY CHART")).is_true() assert_that(self.countries_page.is_label_present("Daily Top 200")).is_true() assert_that(self.countries_page.is_track_present(top_track)).is_true() self.countries_page.select_market_by_name("Global") assert_that(self.countries_page.is_label_present(top_artist)).is_true() assert_that(self.countries_page.is_label_present("SPOTIFY CHART")).is_true() assert_that(self.countries_page.is_label_present("Daily Top 200")).is_true() if self.countries_page.is_track_present(top_track) is False: assert_that(self.countries_page.is_label_present( "No artist tracks are featured in this market's chart currently")).is_true() self.navigation_page.click_back() # Apple self.countries_page.charts_list.select_by_text('APPLE CHART Top 100') assert_that(self.countries_page.chosen_market_value(self.countrycode_spotify_top)).is_true() assert_that(self.countries_page.is_label_present(top_artist)).is_true() assert_that(self.countries_page.is_label_present("APPLE CHART")).is_true() assert_that(self.countries_page.is_label_present("Top 100")).is_true() assert_that(self.countries_page.is_track_present(top_track)).is_true()