Add from and to dates for artist charts, for #44
This commit is contained in:
parent
a254a9fd0c
commit
c587600e16
12
pylast.py
12
pylast.py
|
@ -2158,19 +2158,19 @@ class Metro(_BaseObject):
|
||||||
|
|
||||||
return self.country
|
return self.country
|
||||||
|
|
||||||
def get_artist_chart(self, limit=None, cacheable=True):
|
def get_artist_chart(self, limit=None, from_date=None, to_date=None, cacheable=True):
|
||||||
"""Get a chart of artists for a metro.
|
"""Get a chart of artists for a metro.
|
||||||
Parameters:
|
Parameters:
|
||||||
TODO start (Optional) : Beginning timestamp of the weekly range requested (c.f. geo.getWeeklyChartlist)
|
from_date (Optional) : Beginning timestamp of the weekly range requested
|
||||||
TODO end (Optional) : Ending timestamp of the weekly range requested (c.f. geo.getWeeklyChartlist)
|
to_date (Optional) : Ending timestamp of the weekly range requested
|
||||||
limit (Optional) : The number of results to fetch per page. Defaults to 50.
|
limit (Optional) : The number of results to fetch per page. Defaults to 50.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
if limit: params["limit"] = limit
|
if limit: params["limit"] = limit
|
||||||
# if from_date and to_date:
|
if from_date and to_date:
|
||||||
# params["from"] = from_date
|
params["from"] = from_date
|
||||||
# params["to"] = to_date
|
params["to"] = to_date
|
||||||
|
|
||||||
doc = self._request("geo.getMetroArtistChart", cacheable, params)
|
doc = self._request("geo.getMetroArtistChart", cacheable, params)
|
||||||
|
|
||||||
|
|
|
@ -904,17 +904,6 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertEqual(event.get_venue().location['city'], "Reading")
|
self.assertEqual(event.get_venue().location['city'], "Reading")
|
||||||
|
|
||||||
|
|
||||||
def test_get_metro_artist_chart(self):
|
|
||||||
# Arrange
|
|
||||||
metro = self.network.get_metro("Salamanca", "Spain")
|
|
||||||
|
|
||||||
# Act
|
|
||||||
chart = metro.get_artist_chart()
|
|
||||||
|
|
||||||
# Assert
|
|
||||||
self.assertEqual(type(chart[0]), pylast.TopItem)
|
|
||||||
self.assertEqual(type(chart[0].item), pylast.Artist)
|
|
||||||
|
|
||||||
def test_get_metro_weekly_chart_dates(self):
|
def test_get_metro_weekly_chart_dates(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
# Act
|
# Act
|
||||||
|
@ -926,6 +915,21 @@ class TestPyLast(unittest.TestCase):
|
||||||
(start, end) = dates[0]
|
(start, end) = dates[0]
|
||||||
self.assertLess(start, end)
|
self.assertLess(start, end)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_metro_artist_chart(self):
|
||||||
|
# Arrange
|
||||||
|
metro = self.network.get_metro("Salamanca", "Spain")
|
||||||
|
dates = self.network.get_metro_weekly_chart_dates()
|
||||||
|
(from_date, to_date) = dates[0]
|
||||||
|
|
||||||
|
# Act
|
||||||
|
chart = metro.get_artist_chart(from_date = from_date, to_date = to_date, limit = 1)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
self.assertEqual(len(chart), 1)
|
||||||
|
self.assertEqual(type(chart[0]), pylast.TopItem)
|
||||||
|
self.assertEqual(type(chart[0].item), pylast.Artist)
|
||||||
|
|
||||||
def test_geo_get_metros(self):
|
def test_geo_get_metros(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
# Act
|
# Act
|
||||||
|
|
Loading…
Reference in a new issue