diff --git a/pylast.py b/pylast.py index ad674d7..814e26e 100644 --- a/pylast.py +++ b/pylast.py @@ -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) diff --git a/test_pylast.py b/test_pylast.py index 9859039..7643b52 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -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