-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from alistairmaclean/system-playlists
Add support for system-playlist kind so that "discover" playlists are loaded
- Loading branch information
Showing
4 changed files
with
51 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
""" | ||
Test async playlist | ||
Test async playlists | ||
""" | ||
import pytest_asyncio | ||
import pytest | ||
|
||
from sclib.asyncio import SoundcloudAPI, Playlist | ||
from sclib.asyncio import SoundcloudAPI | ||
|
||
PLAYLIST_URL = 'https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic' | ||
TEST_PLAYLIST = None | ||
pytest_plugins = ('pytest_asyncio',) | ||
|
||
|
||
@pytest_asyncio.fixture(name='test_playlist') | ||
async def playlist_fixture(): | ||
@pytest.fixture(name='sclib') | ||
def sclib_fixture(): | ||
""" Ex playlist """ | ||
return await SoundcloudAPI().resolve(PLAYLIST_URL) | ||
return SoundcloudAPI() | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize("playlist_url", [ | ||
"https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic", | ||
"https://soundcloud.com/discover/sets/artist-stations:127466931", | ||
]) | ||
async def test_playlist_is_resolved(sclib: SoundcloudAPI, playlist_url: str): | ||
""" Test async playlist is resolved """ | ||
await sclib.resolve(playlist_url) | ||
|
||
def test_playlist_size(test_playlist: Playlist): | ||
""" Test async playlist size """ | ||
assert len(test_playlist) > 0 | ||
test_playlist.clean_attributes() | ||
assert len(test_playlist) == len(test_playlist.tracks) | ||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize("playlist_url,expected_playlist_kind", [ | ||
("https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic", "playlist"), | ||
("https://soundcloud.com/discover/sets/artist-stations:127466931", "system-playlist"), | ||
]) | ||
async def test_playlist_type(sclib: SoundcloudAPI, playlist_url: str, expected_playlist_kind: str): | ||
""" Test async playlist type """ | ||
test_playlist = await sclib.resolve(playlist_url) | ||
assert test_playlist.kind == expected_playlist_kind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
""" Test sync playlists """ | ||
|
||
""" | ||
Test async playlists | ||
""" | ||
import pytest | ||
|
||
from sclib import SoundcloudAPI, Playlist | ||
|
||
PLAYLIST_URL = 'https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic' | ||
TEST_PLAYLIST = None | ||
|
||
|
||
@pytest.fixture(name="playlist") | ||
def test_playlist(): | ||
""" Example playlist fixture """ | ||
from sclib.sync import SoundcloudAPI | ||
|
||
return SoundcloudAPI().resolve(PLAYLIST_URL) | ||
|
||
@pytest.fixture(name='sclib') | ||
def sclib_fixture(): | ||
""" Ex playlist """ | ||
return SoundcloudAPI() | ||
|
||
|
||
def test_playlist_size(playlist: Playlist): | ||
""" Test that playlist size is correct """ | ||
assert len(playlist) > 0 and type(len(playlist)) is int | ||
@pytest.mark.parametrize("playlist_url", [ | ||
"https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic", | ||
"https://soundcloud.com/discover/sets/artist-stations:127466931", | ||
]) | ||
def test_playlist_is_resolved(sclib: SoundcloudAPI, playlist_url: str): | ||
""" Test async playlist is resolved """ | ||
sclib.resolve(playlist_url) | ||
|
||
|
||
def test_playlist_fetch_tracks(playlist: Playlist): | ||
""" Test that number of tracks matches size of playlist """ | ||
assert len(playlist.tracks) is len(playlist) | ||
@pytest.mark.parametrize("playlist_url,expected_playlist_kind", [ | ||
("https://soundcloud.com/soundcloud-circuits/sets/web-tempo-future-dance-and-electronic", "playlist"), | ||
("https://soundcloud.com/discover/sets/artist-stations:127466931", "system-playlist"), | ||
]) | ||
def test_playlist_type(sclib: SoundcloudAPI, playlist_url: str, expected_playlist_kind: str): | ||
""" Test async playlist type """ | ||
test_playlist = sclib.resolve(playlist_url) | ||
assert test_playlist.kind == expected_playlist_kind |