Beispiel #1
0
 def test_parse_response(self):
     """ Test parse tracks response on success. """
     client = MagicMock()
     object = suser("Foo", client=client)
     tracks = object._parse_response(mock_tracks_response("bar"), strack)
     self.assertEquals(3, len(tracks))
     for track in tracks:
         self.assertIsInstance(track, strack)
 def test_parse_tracks_response(self):
     """ Test parse tracks response on success. """
     client = MagicMock()
     object = suser("Foo", client=client)
     tracks = object._parse_tracks_response(mock_tracks_response("bar"))
     self.assertEquals(3, len(tracks))
     for track in tracks:
         self.assertIsInstance(track, strack)
Beispiel #3
0
 def test_get_playlists_with_custom_offset_and_limit(self):
     """ Test get user's playlists with custom offset and limit. """
     client = MagicMock()
     client.USER_PLAYLISTS = "/u/%s/p.json?o=%d&l=%d&c="
     object = suser("Foo", client=client)
     object._parse_response = Mock()
     object.get_playlists(10, 20)
     client.get.assert_called_once_with(
         "/u/Foo/p.json?o=10&l=20&c=")
Beispiel #4
0
 def test_get_tracks_with_default_offset_and_limit(self):
     """ Test get user's tracks with default offset and limit. """
     client = MagicMock()
     client.USER_TRACKS = "/u/%s/t.json?o=%d&l=%d&c="
     object = suser("Foo", client=client)
     object._parse_response = Mock()
     object.get_tracks()
     client.get.assert_called_once_with(
         "/u/Foo/t.json?o=0&l=50&c=")
Beispiel #5
0
 def test_get_likes_with_custom_offset_and_limit(self):
     """ Test get user's likes with custom offset and limit. """
     client = MagicMock()
     client.USER_LIKES = "/u/%s/f.json?o=%d&l=%d&c="
     object = suser("Foo", client=client)
     object._parse_tracks_response = Mock()
     object.get_likes(10, 20)
     client.get.assert_called_once_with(
         "/u/Foo/f.json?o=10&l=20&c=")
 def test_get_tracks_with_custom_offset_and_limit(self):
     """ Test get user's tracks with custom offset and limit. """
     client = MagicMock()
     client.USER_TRACKS = "/u/%s/t.json?o=%d&l=%d&c="
     object = suser("Foo", client=client)
     object._parse_tracks_response = Mock()
     object.get_tracks(10, 20)
     client.get.assert_called_once_with(
         "/u/Foo/t.json?o=10&l=20&c=")
 def test_get_likes_with_default_offset_and_limit(self):
     """ Test get user's likes with default offset and limit. """
     client = MagicMock()
     client.USER_LIKES = "/u/%s/f.json?o=%d&l=%d&c="
     object = suser("Foo", client=client)
     object._parse_tracks_response = Mock()
     object.get_likes()
     client.get.assert_called_once_with(
         "/u/Foo/f.json?o=0&l=50&c=")
Beispiel #8
0
 def test_object_has_good_name(self):
     """ Test object has name `foo`. """
     client = Mock()
     object = suser("Foo", client=client)
     self.assertEqual("Foo", object.name)
Beispiel #9
0
                 args.output_dir))
    exit(1)

offset = 0
limit = 50
if args.offset:
    offset = args.offset
if args.limit:
    if args.limit > 200:
        print(serror("Error: tracks limit limited to 200 tracks.."))
        exit(2)
    limit = args.limit

try:
    sclient = sclient(args.client_id)
    suser = suser(args.user, client=sclient)
except serror as e:
    print(e)
    exit(3)

tracks_getter = suser.get_likes
if args.tracks:
    tracks_getter = suser.get_tracks

if args.recursive:
    while True:
        nb = downloader(tracks_getter, args.output_dir, offset, limit)
        if nb == 0:
            break

        offset = offset + limit
 def test_object_has_good_name(self):
     """ Test object has name `foo`. """
     client = Mock()
     object = suser("Foo", client=client)
     self.assertEqual("Foo", object.name)