import pytest import allure from datetime import datetime from assertpy import assert_that entity_type = 'track' input_spotify_monthly_listeners = [ (0, 1000), (1000, 5000), (5000, 10000), (10000, 25000), (25000, 50000), (50000, 100000), (100000, 250000), (250000, 500000), (500000, 1000000), (1000000, 5000000), (5000000, 100000000000), ] input_spotify_streams = [ (0, 1000), (1000, 10000), (10000, 100000), (100000, 500000), (500000, 1000000), (1000000, 5000000), (5000000, 10000000), (10000000, 50000000), (50000000, 100000000000) ] input_spotify_playlists = [ (0, 10), (10, 25), (25, 50), (50, 100), (100, 250), (250, 500), (500, 100000000000) ] input_spotify_popularity = [ (0, 10), (10, 20), (20, 30), (30, 40), (40, 50), (50, 60), (60, 70), (70, 80), (80, 90), (90, 100) ] input_spotify_latest_release = [7, 28, 56, 84] @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-1607") @pytest.mark.parametrize("min_val, max_val", input_spotify_monthly_listeners) def test_spotify_monthly_listeners(api, min_val, max_val): data = {"spotify": {"min_monthly_listeners": min_val, "max_monthly_listeners": max_val}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: tested_value = float(entity['spotify']['monthly_listeners']['current_value']) api.check_entity_in_range(entity, tested_value, min_val, max_val) @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-1607") @pytest.mark.parametrize("min_val, max_val", input_spotify_streams) def test_spotify_streams(api, min_val, max_val): data = {"spotify": {"min_streams": min_val, "max_streams": max_val}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: tested_value = float(entity['spotify']['streams']['current_value']) api.check_entity_in_range(entity, tested_value, min_val, max_val) @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-1607") @pytest.mark.parametrize("min_val, max_val", input_spotify_playlists) def test_spotify_playlists(api, min_val, max_val): data = {"spotify": {"min_playlists": min_val, "max_playlists": max_val}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: tested_value = float(entity['spotify']['playlists']['current_value']) api.check_entity_in_range(entity, tested_value, min_val, max_val) @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-1607") @pytest.mark.parametrize("min_val, max_val", input_spotify_popularity) def test_spotify_popularity(api, min_val, max_val): data = {"spotify": {"min_popularity": min_val, "max_popularity": max_val}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: tested_value = float(entity['spotify']['popularity']['current_value']) api.check_entity_in_range(entity, tested_value, min_val, max_val) @allure.testcase("https://data-analytics.atlassian.net/browse/DNAD-1607") def test_spotify_chart_type(api): data = {"spotify": {"chart_type": "MONTHLY_LISTENERS"}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: actual_chart_type = entity['spotify']['chart_type'] assert_that(actual_chart_type == 'monthly_listeners').is_true() data = {"spotify": {}} entities = api.get_entities(entity_type=entity_type, discovery_data=data) for entity in entities: actual_chart_type = entity['spotify']['chart_type'] assert_that(actual_chart_type == 'streams').is_true()