Add from and to dates for artist charts, for #44

This commit is contained in:
hugovk 2014-03-04 17:58:50 +02:00
parent a254a9fd0c
commit c587600e16
2 changed files with 21 additions and 17 deletions

View file

@ -2158,19 +2158,19 @@ class Metro(_BaseObject):
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.
Parameters:
TODO start (Optional) : Beginning timestamp of the weekly range requested (c.f. geo.getWeeklyChartlist)
TODO end (Optional) : Ending timestamp of the weekly range requested (c.f. geo.getWeeklyChartlist)
from_date (Optional) : Beginning timestamp of the weekly range requested
to_date (Optional) : Ending timestamp of the weekly range requested
limit (Optional) : The number of results to fetch per page. Defaults to 50.
"""
params = self._get_params()
if limit: params["limit"] = limit
# if from_date and to_date:
# params["from"] = from_date
# params["to"] = to_date
if from_date and to_date:
params["from"] = from_date
params["to"] = to_date
doc = self._request("geo.getMetroArtistChart", cacheable, params)

View file

@ -904,17 +904,6 @@ class TestPyLast(unittest.TestCase):
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):
# Arrange
# Act
@ -926,6 +915,21 @@ class TestPyLast(unittest.TestCase):
(start, end) = dates[0]
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):
# Arrange
# Act