Ejemplo n.º 1
0
    def test_get_artist(self, find, time, assert_config):
        time.return_value = 1

        find.return_value = Artist(name="Queen")

        artist = LastService.get_artist("quueee")
        self.assertEqual(Artist(name="Queen"), artist)

        find.assert_called_once_with("quueee")

        artist, ttl = Registry.get("last.fm_artist_quueee")
        self.assertEqual({"name": "Queen"}, artist)

        self.assertEqual(timedelta(days=30, seconds=1).total_seconds(), ttl)
        assert_config.assert_called_once()
Ejemplo n.º 2
0
 def convert(self, value, param, ctx):
     try:
         return LastService.get_artist(value).name
     except Exception:
         self.fail("Unknown artist: %s" % value, param, ctx)