Exemple #1
0
 def test_get_albums_out_of_range(self, mock_get):
     mock_resp = mock.Mock()
     mock_resp.json.return_value = self.fake_albums_resp
     mock_get.return_value = mock_resp
     with self.assertRaises(lastfm.LastFMException):
         lastfm.top_albums('J_Roche', dt.date(2015, 9, 1),
                           charts=self.charts)
Exemple #2
0
 def test_get_albums_out_of_range(self, mock_get):
     mock_resp = mock.Mock()
     mock_resp.json.return_value = self.fake_albums_resp
     mock_get.return_value = mock_resp
     with self.assertRaises(lastfm.LastFMException):
         lastfm.top_albums('J_Roche',
                           dt.date(2015, 9, 1),
                           charts=self.charts)
Exemple #3
0
 def test_get_albums(self, mock_chart, mock_get):
     mock_resp = mock.Mock()
     mock_resp.json.return_value = self.fake_albums_resp
     mock_get.return_value = mock_resp
     albums = lastfm.top_albums('J_Roche', dt.date(2015, 7, 1),
                                charts=self.charts)
     mock_chart.assert_not_called()
     self.assertEqual(len(albums), 10)
Exemple #4
0
 def test_get_albums(self, mock_chart, mock_get):
     mock_resp = mock.Mock()
     mock_resp.json.return_value = self.fake_albums_resp
     mock_get.return_value = mock_resp
     albums = lastfm.top_albums('J_Roche',
                                dt.date(2015, 7, 1),
                                charts=self.charts)
     mock_chart.assert_not_called()
     self.assertEqual(len(albums), 10)
Exemple #5
0
def lastfm_snapshot(username):
    charts = lastfm.chart_list(username)
    six_months_ago = dt.date.today() - dt.timedelta(days=6*30)
    six_months = lastfm.top_albums(username, six_months_ago, charts=charts)
    one_year_ago = dt.date.today() - dt.timedelta(days=365)
    one_year = lastfm.top_albums(username, one_year_ago, charts=charts)
    two_year_ago = dt.date.today() - dt.timedelta(days=2*365)
    two_year = lastfm.top_albums(username, two_year_ago, charts=charts)
    three_year_ago = dt.date.today() - dt.timedelta(days=3*365)
    three_year = lastfm.top_albums(username, three_year_ago, charts=charts)
    four_year_ago = dt.date.today() - dt.timedelta(days=4*365)
    four_year = lastfm.top_albums(username, four_year_ago, charts=charts)
    five_year_ago = dt.date.today() - dt.timedelta(days=5*365)
    five_year = lastfm.top_albums(username, five_year_ago, charts=charts)
    charts = {
        'six_months': six_months,
        'one_year': one_year,
        'two_year': two_year,
        'three_year': three_year,
        'four_year': four_year,
        'five_year': five_year,
    }
    return charts
Exemple #6
0
def lastfm_snapshot(username):
    charts = lastfm.chart_list(username)
    six_months_ago = dt.date.today() - dt.timedelta(days=6 * 30)
    six_months = lastfm.top_albums(username, six_months_ago, charts=charts)
    one_year_ago = dt.date.today() - dt.timedelta(days=365)
    one_year = lastfm.top_albums(username, one_year_ago, charts=charts)
    two_year_ago = dt.date.today() - dt.timedelta(days=2 * 365)
    two_year = lastfm.top_albums(username, two_year_ago, charts=charts)
    three_year_ago = dt.date.today() - dt.timedelta(days=3 * 365)
    three_year = lastfm.top_albums(username, three_year_ago, charts=charts)
    four_year_ago = dt.date.today() - dt.timedelta(days=4 * 365)
    four_year = lastfm.top_albums(username, four_year_ago, charts=charts)
    five_year_ago = dt.date.today() - dt.timedelta(days=5 * 365)
    five_year = lastfm.top_albums(username, five_year_ago, charts=charts)
    charts = {
        'six_months': six_months,
        'one_year': one_year,
        'two_year': two_year,
        'three_year': three_year,
        'four_year': four_year,
        'five_year': five_year,
    }
    return charts