import pytest from app.logger import log ids = ["e49ea9f9-0a74-4623-b3c6-ff819c7c0a4d", "0df146b8-c263-4b09-8318-d99bd8a312d9", "1db2b76f-07e3-4bde-95e3-af67844be0b8", "7dbdec05-bebc-4d98-817e-375d160b5e18", "69ff01e1-a9f1-4bc9-b075-82f9f38c1b71", "06183d1d-7c5b-444b-87ef-6a9231378f0b", "5e6c2c4c-ed1d-403b-a147-28e36900b1c0", "69b73f22-b023-4647-a39b-310f60619fea", "30ebe69f-6379-4a2e-881c-638e4564b1c8", "53d651ce-6038-451e-aba4-4f8c234e1260"] @pytest.mark.parametrize("id_", ids) def test_header(graphql, id_): variables_go = { "id": id_ } variables_insights = { "id": id_ } response_go = graphql.fetch_data('GlobalParticipantMetadata', variables_go) response_insights = graphql.fetch_data('GlobalParticipantStatsV2Query', variables_insights) log.info(f"Response from GO: {response_go}") log.info(f"Response from Insights: {response_insights}") response_go_all_time = response_go['globalParticipantByGpId'][0]['analytics']['streamsAllTime'] response_insights_all_time = response_insights['globalParticipantByGpId'][0]['analytics']['streamsAllTime'] assert response_go_all_time == response_insights_all_time, ( f"GO={response_go_all_time}, " f"Insights={response_insights_all_time}" ) # @pytest.mark.parametrize("id_", ids) # def test_pot(id_): # variables_go = { # "id": id_, # "days": -2, # "startDate": get_dates()['start_date'], # "orderBy": "streamsAllTime", # "topSize": 5, # "daysBack": -28, # "countries": [] # } # variables_insights = { # "limit": 50, # "id": id_, # "type": "SOS", # "startDate": get_dates()['start_date'], # "endDate": get_dates()['end_date'], # "countries": [], # "stores": [], # "distributors": "theorchard,sme,awal" # } # # response_go = graphql_client.fetch_data('GlobalParticipantMetadata', # variables_go) # response_insights = graphql_client.fetch_data( # 'GlobalParticipantStatsV2Query', variables_insights) # log.info(f"Response from GO: {response_go}") # log.info(f"Response from Insights: {response_insights}") # # response_go_all_time = \ # response_go['globalParticipantByGpId'][0]['analytics'][ # 'streamsAllTime'] # response_insights_all_time = \ # response_insights['globalParticipantByGpId'][0]['analytics'][ # 'streamsAllTime'] @pytest.mark.parametrize("id_", ids) def test_top_songs(graphql, id_): variables_go = { "id": id_, "orderBy": "streams_7_days", "countries": [], "orderDir": "DESC", "distributors": "theorchard,awal,sme", "offset": 0, "limit": 50 } variables_insights = { "limit": 50, "offset": 0, "id": id_, "countries": [], "distributors": "theorchard,sme,awal", "orderBy": "streams_7_days", "orderDir": "desc" } response_go = graphql.fetch_data('ParticipantSoundRecordings', variables_go) response_insights = graphql.fetch_data('GlobalParticipantSongsQuery', variables_insights) log.info(f"Response from GO: {response_go}") log.info(f"Response from Insights: {response_insights}") response_go_top_songs = response_go['topGlobalSoundRecordings'] response_insights_top_songs = response_insights['topGlobalSoundRecordings'] for go_top_song, insights_top_song in zip(response_go_top_songs, response_insights_top_songs): assert go_top_song['isrc'] == insights_top_song['isrc'] assert (go_top_song['analytics']['streams']['aggregate']['allTime'] == insights_top_song['analytics']['streams']['aggregate']['allTime'])