import allure import pytest from assertpy import assert_that from src.helpers.test_data_loader import DataLoader @pytest.mark.usefixtures("one_time_set_up") class TestArtist: artist_name = DataLoader.get_artist() data = DataLoader("test_artist_data.json") super_user_artist_1 = data.get("super_user_artist_name_1") super_user_artist_2 = data.get("super_user_artist_name_2") single_user_artist = data.get("single_user_artist_name") @allure.title("View Artist info") @allure.description("User should be able to view Artist base info") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1914") @pytest.mark.smoke @pytest.mark.artist def test_artist_base_info(self): 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_artist_tab() assert_that(self.artist_page.chosen_artist_name(), "Artist name is wrong").is_equal_to(self.artist_name) assert_that(self.artist_page.is_time_interval_present, "Time interval label should be").is_true() assert_that(self.artist_page.is_track_comparison_present, "Track comparison section should be").is_true() assert_that(self.artist_page.is_chart_present('ALL Artist Streams')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY Artist Streams')).is_true() assert_that(self.artist_page.is_chart_present('APPLE Artist Streams')).is_true() assert_that(self.artist_page.is_chart_present('AMAZON Artist Streams')).is_true() assert_that(self.artist_page.is_chart_present('INSTAGRAM Followers')).is_true() assert_that(self.artist_page.is_chart_present('TWITTER Followers')).is_true() assert_that(self.artist_page.is_chart_present('FACEBOOK Page Likes')).is_true() assert_that(self.artist_page.is_chart_present('ALL Top Streaming Markets')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY Demographics')).is_true() assert_that(self.artist_page.is_chart_present('APPLE Demographics')).is_true() assert_that(self.artist_page.are_demographic_elements_present_for('SPOTIFY')).is_true() assert_that(self.artist_page.are_demographic_elements_present_for('APPLE')).is_true() @allure.title("Artist - Streams") @allure.description("User should be able to view Artist Streams page") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1905") @pytest.mark.regression def test_artist_streams(self): 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_artist_tab() # All Streams self.artist_page.charts_list.select_by_text('ALL Artist Streams') assert_that(self.artist_page.is_image_present(), "Image should be shown").is_true() assert_that(self.artist_page.chosen_market_value("worldwide")).is_true() assert_that(self.artist_page.is_label_present("ALL ")).is_true() assert_that(self.artist_page.is_label_present("Streams Worldwide")).is_true() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_2w() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_4w() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.select_market_by_name("The United States") assert_that(self.artist_page.chosen_market_value("us")).is_true() assert_that(self.artist_page.is_label_present("ALL ")).is_true() assert_that(self.artist_page.is_label_present("Streams in the United States")).is_true() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # SPOTIFY Streams self.artist_page.charts_list.select_by_text('SPOTIFY Artist Streams') self.artist_page.select_market_by_name("The United States") assert_that(self.artist_page.chosen_market_value("us")).is_true() assert_that(self.artist_page.is_label_present("SPOTIFY ")).is_true() assert_that(self.artist_page.is_label_present("Streams in the United States")).is_true() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_6w() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_8w() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # APPLE Streams self.artist_page.charts_list.select_by_text('APPLE Artist Streams') assert_that(self.artist_page.is_label_present("APPLE ")).is_true() self.artist_page.select_market_by_name("The United States") assert_that(self.artist_page.is_label_present("Streams in the United States")).is_true() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_26w() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_1y() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.navigation_page.click_back() # AMAZON Streams self.artist_page.charts_list.select_by_text('AMAZON Artist Streams') self.artist_page.select_market_by_name("Canada") assert_that(self.artist_page.is_label_present("AMAZON ")).is_true() assert_that(self.artist_page.is_label_present("Streams in Canada")).is_true() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() self.artist_page.switch_range_to_chart_week() assert_that(self.artist_page.is_stream_data_present(), "No data or Error occurred").is_true() @allure.title("Artist - Social") @allure.description("User should be able to view Artist Social page") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1906") @pytest.mark.regression def test_artist_social(self): 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_artist_tab() # Instagram self.artist_page.charts_list.select_by_text('INSTAGRAM Followers') assert_that(self.artist_page.is_label_present("Social")).is_true() assert_that(self.artist_page.is_label_present("Instagram Followers")).is_true() assert_that(self.navigation_page.get_time_interval_value()).is_equal_to("Last 4 weeks") self.navigation_page.select_period_last_1_year() assert_that(self.navigation_page.get_time_interval_value()).is_equal_to("Last 1 year") self.artist_page.bn_social_twitter.click() assert_that(self.artist_page.is_label_present("Twitter Followers")).is_true() self.artist_page.bn_social_facebook.click() assert_that(self.artist_page.is_label_present("Facebook Page Likes")).is_true() self.artist_page.bn_social_instagram.click() assert_that(self.artist_page.is_label_present("Instagram Followers")).is_true() self.navigation_page.click_back() # Twitter self.artist_page.charts_list.select_by_text('TWITTER Followers') assert_that(self.artist_page.is_label_present("Social")).is_true() assert_that(self.artist_page.is_label_present("Twitter Followers")).is_true() self.navigation_page.click_back() # Facebook self.artist_page.charts_list.select_by_text('FACEBOOK Page Likes') assert_that(self.artist_page.is_label_present("Social")).is_true() assert_that(self.artist_page.is_label_present("Facebook Page Likes")).is_true() @allure.title("Artist - Top Streaming Markets") @allure.description("User should be able to view Artist Top Streaming Markets page") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-2034") @pytest.mark.regression def test_artist_top_streaming(self): 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_artist_tab() # Check country page self.artist_page.charts_list.select_by_text('ALL Top Streaming Markets') # TODO: select exact row assert_that(self.artist_page.is_track_1w_statistics_present(), "1w statistics should be shown").is_true() assert_that(self.artist_page.is_track_2w_statistics_present(), "2w statistics should be shown").is_true() assert_that(self.artist_page.is_track_4w_statistics_present(), "4w statistics should be shown").is_true() assert_that(self.artist_page.is_chart_present('ALL Streams')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY Streams')).is_true() assert_that(self.artist_page.is_chart_present('APPLE Streams')).is_true() assert_that(self.artist_page.is_chart_present('AMAZON Streams')).is_true() assert_that(self.artist_page.is_chart_present('ALL Top Tracks')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY Top Tracks')).is_true() assert_that(self.artist_page.is_chart_present('APPLE Top Tracks')).is_true() assert_that(self.artist_page.is_chart_present('AMAZON Top Tracks')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY CHART Daily Top 200')).is_true() assert_that(self.artist_page.is_chart_present('APPLE CHART Top 100')).is_true() assert_that(self.artist_page.is_chart_present('SPOTIFY Demographics')).is_true() assert_that(self.artist_page.is_chart_present('APPLE Demographics')).is_true() assert_that(self.artist_page.are_demographic_elements_present_for('SPOTIFY')).is_true() assert_that(self.artist_page.are_demographic_elements_present_for('APPLE')).is_true() @allure.title("Change Artist - Superuser") @allure.description("Super User should be able to change artist") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1886") @pytest.mark.regression def test_artist_change_superuser(self): self.login_page.login_as_super_user() self.welcome_page.click_skip_btn() self.artist_selector_page.select_an_artist_by_name(self.super_user_artist_1) assert_that(self.artist_page.chosen_artist_name(), "Artist name is wrong").is_equal_to(self.super_user_artist_1) self.navigation_page.open_artist_selection() self.artist_selector_page.select_an_artist_by_name(self.super_user_artist_2) assert_that(self.artist_page.chosen_artist_name(), "Artist name is wrong").is_equal_to(self.super_user_artist_2) @allure.title("Change Artist - Singleuser") @allure.description("Single User should NOT be able to change artist") @allure.testcase("https://data-analytics.atlassian.net/browse/AMA-1887") @pytest.mark.regression def test_artist_change_singleuser(self): self.login_page.login_as_single_user() self.welcome_page.click_skip_btn() # Count available artists for selection. Only 1 for single user artist_list = self.artist_selector_page.list_artists.texts artist_list.remove('log out') assert_that(len(artist_list)).is_equal_to(1).described_as("Only 1 artist should be available") assert_that(artist_list[0]).is_equal_to(self.single_user_artist) # Select artist and check its name self.artist_selector_page.select_an_artist_by_position(1) assert_that(self.artist_page.chosen_artist_name(), "Artist name is wrong").is_equal_to(self.single_user_artist) # Check there is no appeared items upon trying to change the artist self.navigation_page.open_artist_selection() artist_list = self.artist_selector_page.list_artists.texts artist_list.remove('log out') assert_that(len(artist_list)).is_equal_to(1).described_as("Only 1 artist should be available") self.artist_selector_page.select_an_artist_by_position(1) assert_that(self.artist_page.chosen_artist_name(), "Artist name is wrong").is_equal_to(self.single_user_artist)