import pandas as pd import pytest import functools import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '../djagitit/api')) import luminate # Set the variables we will use for the tests artist_id = 55539156 song_id = 175598336 isrc = 'FR9W12216402' weeks = [202347, 202348] country = 'FR' #initialize the class # Old Luminate API is deprecated, so we skip the tests # and there is no need to initialize the class (impossible to retrieve token) #lum = luminate.Lumos() def check_dataframe(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) assert isinstance(result, pd.DataFrame), "result is not a dataframe" assert result.shape[0] > 0, "result has no rows" assert result.shape[1] > 0, "result has no columns" return wrapper @pytest.mark.skip(reason="Luminate module is deprecated") @pytest.mark.parametrize('country', [None, country]) @pytest.mark.parametrize('weeks', [None, weeks[0], weeks]) @pytest.mark.parametrize('artist_id', [artist_id]) class TestArtist: @check_dataframe def test_artist_volumes_daily(self, artist_id, weeks, country): return lum.artist_volumes_daily(artist_id=artist_id, weeks=weeks, country=country) @check_dataframe def test_artist_volumes_weekly(self, artist_id, weeks, country): return lum.artist_volumes_weekly(artist_id=artist_id, weeks=weeks, country=country) @pytest.mark.skip(reason="Luminate module is deprecated") @pytest.mark.parametrize('country', [None, country]) @pytest.mark.parametrize('weeks', [None, weeks[0], weeks]) @pytest.mark.parametrize('isrc', [isrc]) class TestIsrc: @check_dataframe def test_isrc_volumes_daily(self, isrc, weeks, country): return lum.isrc_volumes_daily(isrc=isrc, weeks=weeks, country=country) @check_dataframe def test_isrc_volumes_weekly(self, isrc, weeks, country): return lum.isrc_volumes_weekly(isrc=isrc, weeks=weeks, country=country) @pytest.mark.skip(reason="Luminate module is deprecated") @pytest.mark.parametrize('country', [None, country]) @pytest.mark.parametrize('weeks', [None, weeks[0], weeks]) @pytest.mark.parametrize('id', [song_id, isrc]) class TestSong: @check_dataframe def test_song_volumes_daily(self, id, weeks, country): return lum.song_volumes_daily(id=id, weeks=weeks, country=country) @check_dataframe def test_song_volumes_weekly(self, id, weeks, country): return lum.song_volumes_weekly(id=id, weeks=weeks, country=country)