import logging import allure import pytest from ui_automation_framework.utils import AppConfig from ui_automation_framework.utils import logger as cl from app.src.api.facade import ApiClient from app.src.helpers.api_data_provider import ApiDataProvider log = cl.Logger(logging.DEBUG) api = ApiClient() api.authorize() data_provider = ApiDataProvider(api) data = data_provider.get_sony_tracks_isrcs(market="us", ignore_response_attaching=True) isrcs = data[0][:10] spotify_isrc = AppConfig.get("spotify_track_isrc") markets = AppConfig.get("top_markets") @pytest.mark.parametrize("isrc", isrcs) @allure.story("AG-4700") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verify matching between portal and go latest date for the track page") @allure.description("Match latest between from spotify-consumer-analytics-compat/latest-date and " "/dsp-api/consumer_analytics/streams-latest-date") def test_latest_date_match(isrc): portal = api.common.get_latest_date_portal(isrc)["body"]["date"] go = api.dsp.get_latest_date_go(isrc) assert portal == go, "Latest dates don't match for isrc: {}".format(isrc) @pytest.mark.parametrize("isrc", isrcs) @pytest.mark.parametrize("market", markets) @allure.story("AG-4700") @allure.severity(allure.severity_level.NORMAL) @allure.title("Verify matching between portal and go global streams count on the track page") @allure.description("Match streams count between /dsp-api/analytics/v1/total-streams-count and /dsp-api/delphi/total_streams_count") def test_global_streams_match(isrc, market): go = api.dsp.get_global_streams_go("isrc={}".format(isrc), "market={}".format(market)) portal = api.dsp.get_global_streams_portal("isrc={}".format(isrc), "market={}".format(market), "per_vendors=true") go_market = go["body"]["market_streams"] go_global = go["body"]["global_streams"] portal_market = portal["body"]["market"] portal_global = portal["body"]["global"] assert portal_market == go_market, "Verification of streams count failed for market value isrc: {}".format(isrc) assert portal_global == go_global, "Verification of streams count failed for global value isrc: {}".format(isrc) # @allure.story("AG-4700") TODO: do we need this test? # @allure.severity(allure.severity_level.NORMAL) # @allure.title("Verify matching between portal and go isSony flag for the track page") # @allure.description("Match streams count between /apollo-api/is-sony/ and /sonyalbums/issony/") # def test_is_sony_match(self): # spotify_id = "2ksOAxtIxY8yElEWw8RhgK" # upc = "194491110918" # portal_is_sony = "" # go_is_sony = self.apollo_api_client.get_is_sony_go( # "upc={}".format(upc), "spotify_ids={}".format(spotify_id), "market=us", token=self.token_mobile # )["body"].get(spotify_id) # portal = self.api_client.get_is_sony_portal( # "market=us", "spotify_ids={}".format(spotify_id), "upc={}".format(upc), token=self.token_mobile # )["body"] # for item in portal: # portal_is_sony = item["isSony"] # self.assertEqual( # portal_is_sony, # go_is_sony, # "Verification for is-sony flag failed for track-id: {} and upc: {}".format(spotify_id, upc), # )