added the variable to tests/unit/entries/test_soundcloud_entries and to entries/variables/soundcloud_variables
This commit is contained in:
parent
e8e1daaec2
commit
e5a5e0d527
3 changed files with 29 additions and 6 deletions
|
|
@ -31,7 +31,9 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
|||
working_directory: str,
|
||||
album: str,
|
||||
album_year: int,
|
||||
total_tracks: int,
|
||||
playlist_metadata: PlaylistMetadata,
|
||||
|
||||
):
|
||||
"""
|
||||
Initialize the album track using album metadata and ytdl metadata for the specific track.
|
||||
|
|
@ -40,6 +42,7 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
|||
self._album = album
|
||||
self._album_year = album_year
|
||||
self._playlist_metadata = playlist_metadata
|
||||
self._total_tracks = total_tracks
|
||||
|
||||
@property
|
||||
def track_number(self) -> int:
|
||||
|
|
@ -51,6 +54,11 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
|||
"""Returns the entry's album name, fetched from its internal album"""
|
||||
return self._album
|
||||
|
||||
@property
|
||||
def total_tracks(self) -> int:
|
||||
"""Returns the entry's total tracks in album for singles this is 1, fetched from its internal album"""
|
||||
return self._total_tracks
|
||||
|
||||
@property
|
||||
def album_year(self) -> int:
|
||||
"""Returns the entry's album year, fetched from its internal album"""
|
||||
|
|
@ -105,6 +113,7 @@ class SoundcloudAlbum(Entry):
|
|||
album=self.title,
|
||||
album_year=self.album_year,
|
||||
soundcloud_track=track,
|
||||
total_tracks = self.track_count,
|
||||
playlist_metadata=PlaylistMetadata(
|
||||
playlist_id=self.uid,
|
||||
playlist_extractor=self.extractor,
|
||||
|
|
@ -120,11 +129,6 @@ class SoundcloudAlbum(Entry):
|
|||
def album_year(self) -> int:
|
||||
"""Returns the album's year, computed by the max upload year amongst all album tracks"""
|
||||
return max(track.upload_year for track in self._single_tracks)
|
||||
|
||||
@property
|
||||
def total_tracks(self) -> int:
|
||||
"""Returns total tracks in album, for singles this is 1"""
|
||||
return len(self.album_tracks(self, False))
|
||||
|
||||
@property
|
||||
def track_count(self) -> int:
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@ class SoundcloudVariables(EntryVariables):
|
|||
return f"{self.track_number:02d}"
|
||||
|
||||
@property
|
||||
def total_tracks(self) -> int:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
The total tracks in album. For singles, it will always be 1.
|
||||
"""
|
||||
if self.kwargs_contains("total_tracks"):
|
||||
return self.kwargs("total_tracks")
|
||||
return 1 #i.e. single does not contain total_tracks
|
||||
@property
|
||||
def album(self) -> str:
|
||||
"""
|
||||
Returns
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ def track_number():
|
|||
def track_number_padded():
|
||||
return "01"
|
||||
|
||||
@pytest.fixture
|
||||
def track_count():
|
||||
return 1
|
||||
|
||||
@pytest.fixture
|
||||
def url():
|
||||
|
|
@ -22,6 +25,9 @@ def url():
|
|||
def is_premiere():
|
||||
return False
|
||||
|
||||
@pytest.fixture()
|
||||
def total_tracks():
|
||||
return 1
|
||||
|
||||
@pytest.fixture
|
||||
def mock_soundcloud_track_to_dict(
|
||||
|
|
@ -31,6 +37,7 @@ def mock_soundcloud_track_to_dict(
|
|||
track_number,
|
||||
track_number_padded,
|
||||
is_premiere,
|
||||
total_tracks
|
||||
):
|
||||
return dict(
|
||||
mock_entry_to_dict,
|
||||
|
|
@ -40,6 +47,7 @@ def mock_soundcloud_track_to_dict(
|
|||
"album": title,
|
||||
"sanitized_album": title,
|
||||
"album_year": upload_year,
|
||||
"total_tracks": total_tracks
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -62,6 +70,7 @@ def validate_soundcloud_track_properties(
|
|||
track_number,
|
||||
track_number_padded,
|
||||
is_premiere,
|
||||
total_tracks
|
||||
):
|
||||
def _validate_soundcloud_track_properties(soundcloud_track: SoundcloudTrack):
|
||||
assert validate_entry_properties(soundcloud_track)
|
||||
|
|
@ -70,7 +79,7 @@ def validate_soundcloud_track_properties(
|
|||
assert soundcloud_track.album == title
|
||||
assert soundcloud_track.sanitized_album == title
|
||||
assert soundcloud_track.album_year == upload_year
|
||||
|
||||
assert soundcloud_track.total_tracks == total_tracks
|
||||
assert soundcloud_track.is_premiere() == is_premiere
|
||||
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue