1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import pytest
- from yandex_music import TrackShort
- @pytest.fixture(scope='class')
- def track_short(track, chart):
- return TrackShort(
- TestTrackShort.id,
- TestTrackShort.timestamp,
- TestTrackShort.album_id,
- TestTrackShort.play_count,
- TestTrackShort.recent,
- chart,
- track,
- TestTrackShort.original_index,
- )
- class TestTrackShort:
- id = 21997388
- timestamp = '2019-11-07T03:00:00+00:00'
- album_id = None
- play_count = 0
- recent = False
- original_index = 23
- def test_expected_values(self, track_short, track, chart):
- assert track_short.id == self.id
- assert track_short.timestamp == self.timestamp
- assert track_short.album_id == self.album_id
- assert track_short.play_count == self.play_count
- assert track_short.recent == self.recent
- assert track_short.track == track
- assert track_short.chart == chart
- assert track_short.original_index == self.original_index
- def test_de_json_none(self, client):
- assert TrackShort.de_json({}, client) is None
- def test_de_list_none(self, client):
- assert TrackShort.de_list([], client) == []
- def test_de_json_required(self, client):
- json_dict = {'id': self.id, 'timestamp': self.timestamp}
- track_short = TrackShort.de_json(json_dict, client)
- assert track_short.id == self.id
- assert track_short.timestamp == self.timestamp
- def test_de_json_all(self, client, track, chart):
- json_dict = {
- 'id': self.id,
- 'timestamp': self.timestamp,
- 'album_id': self.album_id,
- 'play_count': self.play_count,
- 'recent': self.recent,
- 'track': track.to_dict(),
- 'chart': chart.to_dict(),
- 'original_index': self.original_index,
- }
- track_short = TrackShort.de_json(json_dict, client)
- assert track_short.id == self.id
- assert track_short.timestamp == self.timestamp
- assert track_short.album_id == self.album_id
- assert track_short.play_count == self.play_count
- assert track_short.recent == self.recent
- assert track_short.track == track
- assert track_short.chart == chart
- assert track_short.original_index == self.original_index
- def test_equality(self):
- a = TrackShort(self.id, self.timestamp, self.album_id)
- b = TrackShort(23, self.timestamp, self.album_id)
- c = TrackShort(self.id, self.timestamp)
- assert a != b
- assert hash(a) != hash(b)
- assert a is not b
- assert a == c
|