import pytest import allure @pytest.mark.usefixtures("app") class TestAudiencePayload: search_type = 'track' @allure.title("[Search Params Tracks] - Audience - TikTok Views MIN - Payload") @allure.description("As user I want to search tracks by audience TikTok parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-370") @pytest.mark.regression def test_audience_tiktok_views_min(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_tiktok_on(True) # DSP - TIKTOK - ON # AUDIENCE - TIKTOK - min_views min_views = [['1k', 1000], ['10k', 10000], ['100k', 100000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ['10M', 10000000], ] for item in min_views: with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_tiktok_views_min.slide(direction='Right', times=1) self.discovery_page.audience_tiktok_views_min.has_value(item[0]) self.discovery_page.audience_tiktok_views_max.has_value('50M+') expected = {'tiktok': {'min_views': item[1], 'max_views': 100000000000}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected) @allure.title("[Search Params Tracks] - Audience - TikTok Views MAX - Payload") @allure.description("As user I want to search tracks by audience TikTok parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-370") @pytest.mark.regression def test_audience_tiktok_views_max(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_tiktok_on(True) # DSP - TIKTOK - ON # AUDIENCE - TIKTOK - max_views max_views = [['1k', 1000], ['10k', 10000], ['100k', 100000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ['10M', 10000000], ] for item in reversed(max_views): with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_tiktok_views_max.slide(direction='Left', times=1) self.discovery_page.audience_tiktok_views_min.has_value('0') self.discovery_page.audience_tiktok_views_max.has_value(item[0]) expected = {'tiktok': {'min_views': 0, 'max_views': item[1]}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected) @allure.title("[Search Params Tracks] - Audience - Spotify Listeners MIN - Payload") @allure.description("As user I want to search tracks by audience Spotify parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-749") @pytest.mark.regression def test_audience_spotify_listeners_min(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_spotify_on(True) # DSP - SPOTIFY - ON # AUDIENCE - SPOTIFY - min_monthly_listeners min_monthly_listeners = [ ['1k', 1000], ['5k', 5000], ['10k', 10000], ['25k', 25000], ['50k', 50000], ['100k', 100000], ['250k', 250000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ] for item in min_monthly_listeners: with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_spotify_listeners_min.slide(direction='Right', times=1) self.discovery_page.audience_spotify_listeners_min.has_value(item[0]) self.discovery_page.audience_spotify_listeners_max.has_value('10M+') expected = {'spotify': {'min_monthly_listeners': item[1], 'max_monthly_listeners': 100000000000}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected) @allure.title("[Search Params Tracks] - Audience - Spotify Listeners MAX - Payload") @allure.description("As user I want to search tracks by audience Spotify parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-749") @pytest.mark.regression def test_audience_spotify_listeners_max(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_spotify_on(True) # DSP - SPOTIFY - ON # AUDIENCE - SPOTIFY - max_monthly_listeners max_monthly_listeners = [ ['1k', 1000], ['5k', 5000], ['10k', 10000], ['25k', 25000], ['50k', 50000], ['100k', 100000], ['250k', 250000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ] for item in reversed(max_monthly_listeners): with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_spotify_listeners_max.slide(direction='Left', times=1) self.discovery_page.audience_spotify_listeners_min.has_value('0') self.discovery_page.audience_spotify_listeners_max.has_value(item[0]) expected = {'spotify': {'min_monthly_listeners': 0, 'max_monthly_listeners': item[1]}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected) @allure.title("[Search Params Tracks] - Audience - SoundCloud Followers MIN - Payload") @allure.description("As user I want to search tracks by audience SoundCloud parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-747") @pytest.mark.regression def test_audience_soundcloud_followers_min(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_soundcloud_on(True) # DSP - SOUNDCLOUD - ON # AUDIENCE - SOUNDCLOUD - min_followers min_followers = [['1k', 1000], ['5k', 5000], ['10k', 10000], ['25k', 25000], ['50k', 50000], ['100k', 100000], ['250k', 250000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ] for item in min_followers: with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_soundcloud_followers_min.slide(direction='Right', times=1) self.discovery_page.audience_soundcloud_followers_min.has_value(item[0]) self.discovery_page.audience_soundcloud_followers_max.has_value('10M+') expected = {'soundcloud': {'min_followers': item[1], 'max_followers': 100000000000}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected) @allure.title("[Search Params Tracks] - Audience - SoundCloud Followers MAX - Payload") @allure.description("As user I want to search tracks by audience SoundCloud parameters") @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-747") @pytest.mark.regression def test_audience_soundcloud_followers_max(self): self.app.go_to(self.discovery_page.url) self.discovery_page.is_page_loaded() self.discovery_page.switch_scope_to_tracks() self.discovery_page.dsp_soundcloud_on(True) # DSP - SOUNDCLOUD - ON # AUDIENCE - SOUNDCLOUD - max_followers max_followers = [['1k', 1000], ['5k', 5000], ['10k', 10000], ['25k', 25000], ['50k', 50000], ['100k', 100000], ['250k', 250000], ['500k', 500000], ['1M', 1000000], ['5M', 5000000], ] for item in reversed(max_followers): with self.app.page.expect_request(self.discovery_page.api_track_total_count) as total_count: self.discovery_page.audience_soundcloud_followers_max.slide(direction='Left', times=1) self.discovery_page.audience_soundcloud_followers_min.has_value('0') self.discovery_page.audience_soundcloud_followers_max.has_value(item[0]) expected = {'soundcloud': {'min_followers': 0, 'max_followers': item[1]}} self.discovery_page.click_discovery_and_compare_payloads_with_diff_and_return(self.search_type, total_count, expected)