示例#1
0
    def test_equality(self, track_short):
        a = TracksList(self.uid, self.revision, [track_short])
        b = TracksList(123, self.revision, [track_short])
        c = TracksList(self.uid, 10, [track_short])

        assert a != b
        assert hash(a) != hash(b)
        assert a is not b

        assert a == c
示例#2
0
    def test_de_json_all(self, client, track_short):
        json_dict = {
            'uid': self.uid,
            'revision': self.revision,
            'tracks': [track_short.to_dict()]
        }
        tracks_list = TracksList.de_json(json_dict, client)

        assert tracks_list.uid == self.uid
        assert tracks_list.revision == self.revision
        assert tracks_list.tracks == [track_short]
示例#3
0
    def users_dislikes_tracks(self, user_id: int or str = None, if_modified_since_revision=0,
                              timeout=None, *args, **kwargs):
        if user_id is None:
            user_id = self.account.uid

        url = f'{self.base_url}/users/{user_id}/dislikes/tracks'

        result = self._request.get(url, {'if_modified_since_revision': if_modified_since_revision},
                                   timeout=timeout, *args, **kwargs)

        return TracksList.de_json(result.get('library'), self)
示例#4
0
    def _get_likes(self, object_type, user_id: int or str = None, params=None, timeout=None, *args, **kwargs):
        if user_id is None:
            user_id = self.account.uid

        url = f'{self.base_url}/users/{user_id}/likes/{object_type}s'

        result = self._request.get(url, params, timeout=timeout, *args, **kwargs)

        if object_type == 'track':
            return TracksList.de_json(result.get('library'), self)

        return de_list_likes.get(object_type)(result, self)
示例#5
0
def tracks_list(track_short):
    return TracksList(TestTracksList.uid, TestTracksList.revision,
                      [track_short])
示例#6
0
 def test_de_json_none(self, client):
     assert TracksList.de_json({}, client) is None