test restructuring via pytest
This commit is contained in:
parent
d1ac87ce6e
commit
69dd4a9f2f
19 changed files with 858 additions and 619 deletions
126
tests/mixins/test_browsing.py
Normal file
126
tests/mixins/test_browsing.py
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
import warnings
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestBrowsing:
|
||||
def test_get_home(self, yt, yt_auth):
|
||||
result = yt.get_home(limit=6)
|
||||
assert len(result) >= 6
|
||||
result = yt_auth.get_home(limit=15)
|
||||
assert len(result) >= 15
|
||||
|
||||
def test_get_artist(self, yt):
|
||||
results = yt.get_artist("MPLAUCmMUZbaYdNH0bEd1PAlAqsA")
|
||||
assert len(results) == 14
|
||||
|
||||
# test correctness of related artists
|
||||
related = results["related"]["results"]
|
||||
assert len(
|
||||
[x for x in related if set(x.keys()) == {"browseId", "subscribers", "title", "thumbnails"}]
|
||||
) == len(related)
|
||||
|
||||
results = yt.get_artist("UCLZ7tlKC06ResyDmEStSrOw") # no album year
|
||||
assert len(results) >= 11
|
||||
|
||||
def test_get_artist_albums(self, yt):
|
||||
artist = yt.get_artist("UCj5ZiBBqpe0Tg4zfKGHEFuQ")
|
||||
results = yt.get_artist_albums(artist["albums"]["browseId"], artist["albums"]["params"])
|
||||
assert len(results) > 0
|
||||
|
||||
def test_get_artist_singles(self, yt):
|
||||
artist = yt.get_artist("UCAeLFBCQS7FvI8PvBrWvSBg")
|
||||
results = yt.get_artist_albums(artist["singles"]["browseId"], artist["singles"]["params"])
|
||||
assert len(results) > 0
|
||||
|
||||
def test_get_user(self, yt):
|
||||
results = yt.get_user("UC44hbeRoCZVVMVg5z0FfIww")
|
||||
assert len(results) == 3
|
||||
|
||||
def test_get_user_playlists(self, yt_auth):
|
||||
results = yt_auth.get_user("UCPVhZsC2od1xjGhgEc2NEPQ") # Vevo playlists
|
||||
results = yt_auth.get_user_playlists("UCPVhZsC2od1xjGhgEc2NEPQ", results["playlists"]["params"])
|
||||
assert len(results) > 100
|
||||
|
||||
def test_get_album_browse_id(self, yt, sample_album):
|
||||
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
|
||||
browse_id = yt.get_album_browse_id("OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY")
|
||||
assert browse_id == sample_album
|
||||
|
||||
def test_get_album_browse_id_issue_470(self, yt):
|
||||
escaped_browse_id = yt.get_album_browse_id("OLAK5uy_nbMYyrfeg5ZgknoOsOGBL268hGxtcbnDM")
|
||||
assert escaped_browse_id == "MPREb_scJdtUCpPE2"
|
||||
|
||||
def test_get_album(self, yt, yt_auth, sample_album):
|
||||
results = yt_auth.get_album(sample_album)
|
||||
assert len(results) >= 9
|
||||
assert results["tracks"][0]["isExplicit"]
|
||||
assert all(item["views"] is not None for item in results["tracks"])
|
||||
assert all(item["album"] is not None for item in results["tracks"])
|
||||
assert "feedbackTokens" in results["tracks"][0]
|
||||
assert len(results["other_versions"]) >= 1 # appears to be regional
|
||||
results = yt.get_album("MPREb_BQZvl3BFGay")
|
||||
assert len(results["tracks"]) == 7
|
||||
assert len(results["tracks"][0]["artists"]) == 1
|
||||
results = yt.get_album("MPREb_rqH94Zr3NN0")
|
||||
assert len(results["tracks"][0]["artists"]) == 2
|
||||
|
||||
def test_get_song(self, config, yt, yt_oauth, sample_video):
|
||||
song = yt_oauth.get_song(config["uploads"]["private_upload_id"]) # private upload
|
||||
assert len(song) == 5
|
||||
song = yt.get_song(sample_video)
|
||||
assert len(song["streamingData"]["adaptiveFormats"]) >= 10
|
||||
|
||||
def test_get_song_related_content(self, yt_oauth, sample_video):
|
||||
song = yt_oauth.get_watch_playlist(sample_video)
|
||||
song = yt_oauth.get_song_related(song["related"])
|
||||
assert len(song) >= 5
|
||||
|
||||
def test_get_lyrics(self, config, yt, sample_video):
|
||||
playlist = yt.get_watch_playlist(sample_video)
|
||||
lyrics_song = yt.get_lyrics(playlist["lyrics"])
|
||||
assert lyrics_song["lyrics"] is not None
|
||||
assert lyrics_song["source"] is not None
|
||||
|
||||
playlist = yt.get_watch_playlist(config["uploads"]["private_upload_id"])
|
||||
assert playlist["lyrics"] is None
|
||||
with pytest.raises(Exception):
|
||||
yt.get_lyrics(playlist["lyrics"])
|
||||
|
||||
def test_get_signatureTimestamp(self, yt):
|
||||
signature_timestamp = yt.get_signatureTimestamp()
|
||||
assert signature_timestamp is not None
|
||||
|
||||
def test_set_tasteprofile(self, yt, yt_brand):
|
||||
with pytest.raises(Exception):
|
||||
yt.set_tasteprofile(["not an artist"])
|
||||
taste_profile = yt.get_tasteprofile()
|
||||
assert yt.set_tasteprofile(list(taste_profile)[:5], taste_profile) is None
|
||||
|
||||
with pytest.raises(Exception):
|
||||
yt_brand.set_tasteprofile(["test", "test2"])
|
||||
taste_profile = yt_brand.get_tasteprofile()
|
||||
assert yt_brand.set_tasteprofile(list(taste_profile)[:1], taste_profile) is None
|
||||
|
||||
def test_get_tasteprofile(self, yt, yt_oauth):
|
||||
result = yt.get_tasteprofile()
|
||||
assert len(result) >= 0
|
||||
|
||||
result = yt_oauth.get_tasteprofile()
|
||||
assert len(result) >= 0
|
||||
|
||||
def test_get_search_suggestions(self, yt, yt_brand, yt_auth):
|
||||
result = yt.get_search_suggestions("fade")
|
||||
assert len(result) >= 0
|
||||
|
||||
result = yt.get_search_suggestions("fade", detailed_runs=True)
|
||||
assert len(result) >= 0
|
||||
|
||||
# add search term to history
|
||||
first_pass = yt_brand.search("b")
|
||||
assert len(first_pass) > 0
|
||||
|
||||
# get results
|
||||
results = yt_auth.get_search_suggestions("b", detailed_runs=True)
|
||||
assert len(results) > 0
|
||||
assert any(not item["fromHistory"] for item in results)
|
||||
17
tests/mixins/test_explore.py
Normal file
17
tests/mixins/test_explore.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class TestExplore:
|
||||
def test_get_mood_playlists(self, yt):
|
||||
categories = yt.get_mood_categories()
|
||||
assert len(list(categories)) > 0
|
||||
cat = list(categories)[0]
|
||||
assert len(categories[cat]) > 0
|
||||
playlists = yt.get_mood_playlists(categories[cat][0]["params"])
|
||||
assert len(playlists) > 0
|
||||
|
||||
def test_get_charts(self, yt, yt_oauth):
|
||||
charts = yt_oauth.get_charts()
|
||||
# songs section appears to be removed currently (US)
|
||||
assert len(charts) >= 3
|
||||
charts = yt.get_charts(country="US")
|
||||
assert len(charts) == 5
|
||||
charts = yt.get_charts(country="BE")
|
||||
assert len(charts) == 4
|
||||
105
tests/mixins/test_library.py
Normal file
105
tests/mixins/test_library.py
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import pytest
|
||||
|
||||
|
||||
class TestLibrary:
|
||||
def test_get_library_playlists(self, config, yt_oauth, yt_empty):
|
||||
playlists = yt_oauth.get_library_playlists(50)
|
||||
assert len(playlists) > 25
|
||||
|
||||
playlists = yt_oauth.get_library_playlists(None)
|
||||
assert len(playlists) >= config.getint("limits", "library_playlists")
|
||||
|
||||
playlists = yt_empty.get_library_playlists()
|
||||
assert len(playlists) <= 1 # "Episodes saved for later"
|
||||
|
||||
def test_get_library_songs(self, config, yt_oauth, yt_empty):
|
||||
with pytest.raises(Exception):
|
||||
yt_oauth.get_library_songs(None, True)
|
||||
songs = yt_oauth.get_library_songs(100)
|
||||
assert len(songs) >= 100
|
||||
songs = yt_oauth.get_library_songs(200, validate_responses=True)
|
||||
assert len(songs) >= config.getint("limits", "library_songs")
|
||||
songs = yt_oauth.get_library_songs(order="a_to_z")
|
||||
assert len(songs) >= 25
|
||||
songs = yt_empty.get_library_songs()
|
||||
assert len(songs) == 0
|
||||
|
||||
def test_get_library_albums(self, yt_oauth, yt_brand, yt_empty):
|
||||
albums = yt_oauth.get_library_albums(100)
|
||||
assert len(albums) > 50
|
||||
for album in albums:
|
||||
assert "playlistId" in album
|
||||
albums = yt_brand.get_library_albums(100, order="a_to_z")
|
||||
assert len(albums) > 50
|
||||
albums = yt_brand.get_library_albums(100, order="z_to_a")
|
||||
assert len(albums) > 50
|
||||
albums = yt_brand.get_library_albums(100, order="recently_added")
|
||||
assert len(albums) > 50
|
||||
albums = yt_empty.get_library_albums()
|
||||
assert len(albums) == 0
|
||||
|
||||
def test_get_library_artists(self, config, yt_auth, yt_oauth, yt_brand, yt_empty):
|
||||
artists = yt_auth.get_library_artists(50)
|
||||
assert len(artists) > 40
|
||||
artists = yt_oauth.get_library_artists(order="a_to_z", limit=50)
|
||||
assert len(artists) > 40
|
||||
artists = yt_brand.get_library_artists(limit=None)
|
||||
assert len(artists) > config.getint("limits", "library_artists")
|
||||
artists = yt_empty.get_library_artists()
|
||||
assert len(artists) == 0
|
||||
|
||||
def test_get_library_subscriptions(self, config, yt_brand, yt_empty):
|
||||
artists = yt_brand.get_library_subscriptions(50)
|
||||
assert len(artists) > 40
|
||||
artists = yt_brand.get_library_subscriptions(order="z_to_a")
|
||||
assert len(artists) > 20
|
||||
artists = yt_brand.get_library_subscriptions(limit=None)
|
||||
assert len(artists) > config.getint("limits", "library_subscriptions")
|
||||
artists = yt_empty.get_library_subscriptions()
|
||||
assert len(artists) == 0
|
||||
|
||||
def test_get_liked_songs(self, yt_brand, yt_empty):
|
||||
songs = yt_brand.get_liked_songs(200)
|
||||
assert len(songs["tracks"]) > 100
|
||||
songs = yt_empty.get_liked_songs()
|
||||
assert songs["trackCount"] == 0
|
||||
|
||||
def test_get_history(self, yt_oauth):
|
||||
songs = yt_oauth.get_history()
|
||||
assert len(songs) > 0
|
||||
|
||||
def test_manipulate_history_items(self, yt_auth, sample_video):
|
||||
song = yt_auth.get_song(sample_video)
|
||||
response = yt_auth.add_history_item(song)
|
||||
assert response.status_code == 204
|
||||
songs = yt_auth.get_history()
|
||||
assert len(songs) > 0
|
||||
response = yt_auth.remove_history_items([songs[0]["feedbackToken"]])
|
||||
assert "feedbackResponses" in response
|
||||
|
||||
def test_rate_song(self, yt_auth, sample_video):
|
||||
response = yt_auth.rate_song(sample_video, "LIKE")
|
||||
assert "actions" in response
|
||||
response = yt_auth.rate_song(sample_video, "INDIFFERENT")
|
||||
assert "actions" in response
|
||||
|
||||
def test_edit_song_library_status(self, yt_brand, sample_album):
|
||||
album = yt_brand.get_album(sample_album)
|
||||
response = yt_brand.edit_song_library_status(album["tracks"][0]["feedbackTokens"]["add"])
|
||||
album = yt_brand.get_album(sample_album)
|
||||
assert album["tracks"][0]["inLibrary"]
|
||||
assert response["feedbackResponses"][0]["isProcessed"]
|
||||
response = yt_brand.edit_song_library_status(album["tracks"][0]["feedbackTokens"]["remove"])
|
||||
album = yt_brand.get_album(sample_album)
|
||||
assert not album["tracks"][0]["inLibrary"]
|
||||
assert response["feedbackResponses"][0]["isProcessed"]
|
||||
|
||||
def test_rate_playlist(self, yt_auth):
|
||||
response = yt_auth.rate_playlist("OLAK5uy_l3g4WcHZsEx_QuEDZzWEiyFzZl6pL0xZ4", "LIKE")
|
||||
assert "actions" in response
|
||||
response = yt_auth.rate_playlist("OLAK5uy_l3g4WcHZsEx_QuEDZzWEiyFzZl6pL0xZ4", "INDIFFERENT")
|
||||
assert "actions" in response
|
||||
|
||||
def test_subscribe_artists(self, yt_auth):
|
||||
yt_auth.subscribe_artists(["UCUDVBtnOQi4c7E8jebpjc9Q", "UCiMhD4jzUqG-IgPzUmmytRQ"])
|
||||
yt_auth.unsubscribe_artists(["UCUDVBtnOQi4c7E8jebpjc9Q", "UCiMhD4jzUqG-IgPzUmmytRQ"])
|
||||
75
tests/mixins/test_playlists.py
Normal file
75
tests/mixins/test_playlists.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestPlaylists:
|
||||
def test_get_playlist_foreign(self, yt, yt_auth, yt_oauth):
|
||||
with pytest.raises(Exception):
|
||||
yt.get_playlist("PLABC")
|
||||
playlist = yt_auth.get_playlist("PLk5BdzXBUiUe8Q5I13ZSCD8HbxMqJUUQA", limit=300, suggestions_limit=7)
|
||||
assert len(playlist["duration"]) > 5
|
||||
assert len(playlist["tracks"]) > 200
|
||||
assert "suggestions" not in playlist
|
||||
|
||||
yt.get_playlist("RDATgXd-")
|
||||
assert len(playlist["tracks"]) >= 100
|
||||
|
||||
playlist = yt_oauth.get_playlist("PLj4BSJLnVpNyIjbCWXWNAmybc97FXLlTk", limit=None, related=True)
|
||||
assert len(playlist["tracks"]) > 200
|
||||
assert len(playlist["related"]) == 0
|
||||
|
||||
def test_get_playlist_owned(self, config, yt_brand):
|
||||
playlist = yt_brand.get_playlist(config["playlists"]["own"], related=True, suggestions_limit=21)
|
||||
assert len(playlist["tracks"]) < 100
|
||||
assert len(playlist["suggestions"]) == 21
|
||||
assert len(playlist["related"]) == 10
|
||||
|
||||
def test_edit_playlist(self, config, yt_brand):
|
||||
playlist = yt_brand.get_playlist(config["playlists"]["own"])
|
||||
response = yt_brand.edit_playlist(
|
||||
playlist["id"],
|
||||
title="",
|
||||
description="",
|
||||
privacyStatus="PRIVATE",
|
||||
moveItem=(
|
||||
playlist["tracks"][1]["setVideoId"],
|
||||
playlist["tracks"][0]["setVideoId"],
|
||||
),
|
||||
)
|
||||
assert response == "STATUS_SUCCEEDED", "Playlist edit failed"
|
||||
yt_brand.edit_playlist(
|
||||
playlist["id"],
|
||||
title=playlist["title"],
|
||||
description=playlist["description"],
|
||||
privacyStatus=playlist["privacy"],
|
||||
moveItem=(
|
||||
playlist["tracks"][0]["setVideoId"],
|
||||
playlist["tracks"][1]["setVideoId"],
|
||||
),
|
||||
)
|
||||
assert response == "STATUS_SUCCEEDED", "Playlist edit failed"
|
||||
|
||||
def test_end2end(self, config, yt_brand, sample_video):
|
||||
playlist_id = yt_brand.create_playlist(
|
||||
"test",
|
||||
"test description",
|
||||
source_playlist="OLAK5uy_lGQfnMNGvYCRdDq9ZLzJV2BJL2aHQsz9Y",
|
||||
)
|
||||
assert len(playlist_id) == 34, "Playlist creation failed"
|
||||
yt_brand.edit_playlist(playlist_id, addToTop=True)
|
||||
response = yt_brand.add_playlist_items(
|
||||
playlist_id,
|
||||
[sample_video, sample_video],
|
||||
source_playlist="OLAK5uy_nvjTE32aFYdFN7HCyMv3cGqD3wqBb4Jow",
|
||||
duplicates=True,
|
||||
)
|
||||
assert response["status"] == "STATUS_SUCCEEDED", "Adding playlist item failed"
|
||||
assert len(response["playlistEditResults"]) > 0, "Adding playlist item failed"
|
||||
time.sleep(3)
|
||||
yt_brand.edit_playlist(playlist_id, addToTop=False)
|
||||
playlist = yt_brand.get_playlist(playlist_id, related=True)
|
||||
assert len(playlist["tracks"]) == 46, "Getting playlist items failed"
|
||||
response = yt_brand.remove_playlist_items(playlist_id, playlist["tracks"])
|
||||
assert response == "STATUS_SUCCEEDED", "Playlist item removal failed"
|
||||
yt_brand.delete_playlist(playlist_id)
|
||||
90
tests/mixins/test_search.py
Normal file
90
tests/mixins/test_search.py
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import pytest
|
||||
|
||||
|
||||
class TestSearch:
|
||||
def test_search_exceptions(self):
|
||||
query = "edm playlist"
|
||||
with pytest.raises(Exception):
|
||||
yt_auth.search(query, filter="song")
|
||||
with pytest.raises(Exception):
|
||||
yt_auth.search(query, scope="upload")
|
||||
|
||||
@pytest.mark.parametrize("query", ["Monekes", "qllwlwl", "heun"])
|
||||
def test_search_queries(self, yt, yt_brand, query: str) -> None:
|
||||
results = yt_brand.search(query)
|
||||
assert ["resultType" in r for r in results] == [True] * len(results)
|
||||
assert len(results) >= 10
|
||||
results = yt.search(query)
|
||||
assert len(results) >= 10
|
||||
|
||||
def test_search_ignore_spelling(self, yt_auth):
|
||||
results = yt_auth.search("Martin Stig Andersen - Deteriation", ignore_spelling=True)
|
||||
assert len(results) > 0
|
||||
|
||||
def test_search_filters(self, yt_auth):
|
||||
query = "hip hop playlist"
|
||||
results = yt_auth.search(query, filter="songs")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "song" for item in results)
|
||||
results = yt_auth.search(query, filter="videos")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "video" for item in results)
|
||||
results = yt_auth.search(query, filter="albums", limit=40)
|
||||
assert len(results) > 20
|
||||
assert all(item["resultType"] == "album" for item in results)
|
||||
results = yt_auth.search("project-2", filter="artists", ignore_spelling=True)
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "artist" for item in results)
|
||||
results = yt_auth.search("classical music", filter="playlists")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "playlist" for item in results)
|
||||
results = yt_auth.search("clasical music", filter="playlists", ignore_spelling=True)
|
||||
assert len(results) > 10
|
||||
results = yt_auth.search("clasic rock", filter="community_playlists", ignore_spelling=True)
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "playlist" for item in results)
|
||||
results = yt_auth.search("hip hop", filter="featured_playlists")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "playlist" for item in results)
|
||||
results = yt_auth.search("some user", filter="profiles")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "profile" for item in results)
|
||||
results = yt_auth.search(query, filter="podcasts")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "podcast" for item in results)
|
||||
results = yt_auth.search(query, filter="episodes")
|
||||
assert len(results) > 10
|
||||
assert all(item["resultType"] == "episode" for item in results)
|
||||
|
||||
def test_search_uploads(self, config, yt, yt_oauth):
|
||||
with pytest.raises(Exception, match="No filter can be set when searching uploads"):
|
||||
yt.search(
|
||||
config["queries"]["uploads_songs"],
|
||||
filter="songs",
|
||||
scope="uploads",
|
||||
limit=40,
|
||||
)
|
||||
results = yt_oauth.search(config["queries"]["uploads_songs"], scope="uploads", limit=40)
|
||||
assert len(results) > 20
|
||||
|
||||
def test_search_library(self, config, yt_oauth):
|
||||
results = yt_oauth.search(config["queries"]["library_any"], scope="library")
|
||||
assert len(results) > 5
|
||||
results = yt_oauth.search(
|
||||
config["queries"]["library_songs"], filter="songs", scope="library", limit=40
|
||||
)
|
||||
assert len(results) > 10
|
||||
results = yt_oauth.search(
|
||||
config["queries"]["library_albums"], filter="albums", scope="library", limit=40
|
||||
)
|
||||
assert len(results) >= 4
|
||||
results = yt_oauth.search(
|
||||
config["queries"]["library_artists"], filter="artists", scope="library", limit=40
|
||||
)
|
||||
assert len(results) >= 1
|
||||
results = yt_oauth.search(config["queries"]["library_playlists"], filter="playlists", scope="library")
|
||||
assert len(results) >= 1
|
||||
with pytest.raises(Exception):
|
||||
yt_oauth.search("beatles", filter="community_playlists", scope="library", limit=40)
|
||||
with pytest.raises(Exception):
|
||||
yt_oauth.search("beatles", filter="featured_playlists", scope="library", limit=40)
|
||||
62
tests/mixins/test_uploads.py
Normal file
62
tests/mixins/test_uploads.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import get_resource
|
||||
|
||||
|
||||
class TestUploads:
|
||||
def test_get_library_upload_songs(self, yt_oauth, yt_empty):
|
||||
results = yt_oauth.get_library_upload_songs(50, order="z_to_a")
|
||||
assert len(results) > 25
|
||||
|
||||
results = yt_empty.get_library_upload_songs(100)
|
||||
assert len(results) == 0
|
||||
|
||||
def test_get_library_upload_albums(self, config, yt_oauth, yt_empty):
|
||||
results = yt_oauth.get_library_upload_albums(50, order="a_to_z")
|
||||
assert len(results) > 40
|
||||
|
||||
albums = yt_oauth.get_library_upload_albums(None)
|
||||
assert len(albums) >= config.getint("limits", "library_upload_albums")
|
||||
|
||||
results = yt_empty.get_library_upload_albums(100)
|
||||
assert len(results) == 0
|
||||
|
||||
def test_get_library_upload_artists(self, config, yt_oauth, yt_empty):
|
||||
artists = yt_oauth.get_library_upload_artists(None)
|
||||
assert len(artists) >= config.getint("limits", "library_upload_artists")
|
||||
|
||||
results = yt_oauth.get_library_upload_artists(50, order="recently_added")
|
||||
assert len(results) >= 25
|
||||
|
||||
results = yt_empty.get_library_upload_artists(100)
|
||||
assert len(results) == 0
|
||||
|
||||
def test_upload_song_exceptions(self, config, yt_auth, yt_oauth):
|
||||
with pytest.raises(Exception, match="The provided file does not exist."):
|
||||
yt_auth.upload_song("song.wav")
|
||||
with tempfile.NamedTemporaryFile(suffix="wav") as temp, pytest.raises(
|
||||
Exception, match="The provided file type is not supported"
|
||||
):
|
||||
yt_auth.upload_song(temp.name)
|
||||
with pytest.raises(Exception, match="Please provide browser authentication"):
|
||||
yt_oauth.upload_song(config["uploads"]["file"])
|
||||
|
||||
def test_upload_song(self, config, yt_auth):
|
||||
response = yt_auth.upload_song(get_resource(config["uploads"]["file"]))
|
||||
assert response.status_code == 409
|
||||
|
||||
@pytest.mark.skip(reason="Do not delete uploads")
|
||||
def test_delete_upload_entity(self, yt_oauth):
|
||||
results = yt_oauth.get_library_upload_songs()
|
||||
response = yt_oauth.delete_upload_entity(results[0]["entityId"])
|
||||
assert response == "STATUS_SUCCEEDED"
|
||||
|
||||
def test_get_library_upload_album(self, config, yt_oauth):
|
||||
album = yt_oauth.get_library_upload_album(config["uploads"]["private_album_id"])
|
||||
assert len(album["tracks"]) > 0
|
||||
|
||||
def test_get_library_upload_artist(self, config, yt_oauth):
|
||||
tracks = yt_oauth.get_library_upload_artist(config["uploads"]["private_artist_id"], 100)
|
||||
assert len(tracks) > 0
|
||||
16
tests/mixins/test_watch.py
Normal file
16
tests/mixins/test_watch.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
class TestWatch:
|
||||
def test_get_watch_playlist(self, config, yt, yt_brand, yt_oauth):
|
||||
playlist = yt_oauth.get_watch_playlist(
|
||||
playlistId="RDAMPLOLAK5uy_l_fKDQGOUsk8kbWsm9s86n4-nZNd2JR8Q",
|
||||
radio=True,
|
||||
limit=90,
|
||||
)
|
||||
assert len(playlist["tracks"]) >= 90
|
||||
playlist = yt_oauth.get_watch_playlist("9mWr4c_ig54", limit=50)
|
||||
assert len(playlist["tracks"]) > 45
|
||||
playlist = yt_oauth.get_watch_playlist("UoAf_y9Ok4k") # private track
|
||||
assert len(playlist["tracks"]) >= 25
|
||||
playlist = yt.get_watch_playlist(playlistId=config["albums"]["album_browse_id"], shuffle=True)
|
||||
assert len(playlist["tracks"]) == config.getint("albums", "album_track_length")
|
||||
playlist = yt_brand.get_watch_playlist(playlistId=config["playlists"]["own"], shuffle=True)
|
||||
assert len(playlist["tracks"]) == config.getint("playlists", "own_length")
|
||||
Loading…
Reference in a new issue