drop 3.8, add pytest-retry (#592)
* drop 3.8, add pytest-retry * fix mypy * fix missing import
This commit is contained in:
parent
08d9f3049c
commit
828b1b9810
26 changed files with 321 additions and 362 deletions
|
|
@ -4,6 +4,7 @@ import time
|
|||
import pytest
|
||||
|
||||
from tests.conftest import get_resource
|
||||
from ytmusicapi.enums import ResponseStatus
|
||||
from ytmusicapi.ytmusic import YTMusic
|
||||
|
||||
|
||||
|
|
@ -38,8 +39,9 @@ class TestUploads:
|
|||
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"
|
||||
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"):
|
||||
|
|
@ -59,14 +61,14 @@ class TestUploads:
|
|||
for song in songs:
|
||||
if song.get("title") in config["uploads"]["file"]:
|
||||
delete_response = yt_auth.delete_upload_entity(song["entityId"])
|
||||
assert delete_response == "STATUS_SUCCEEDED"
|
||||
assert delete_response == ResponseStatus.SUCCEEDED
|
||||
# Need to wait for song to be fully deleted
|
||||
time.sleep(10)
|
||||
# Now re-upload
|
||||
upload_response = yt_auth.upload_song(get_resource(config["uploads"]["file"]))
|
||||
|
||||
assert (
|
||||
upload_response == "STATUS_SUCCEEDED" or upload_response.status_code == 200
|
||||
upload_response == ResponseStatus.SUCCEEDED or upload_response.status_code == 200
|
||||
), f"Song failed to upload {upload_response}"
|
||||
|
||||
# Wait for upload to finish processing and verify it can be retrieved
|
||||
|
|
@ -86,7 +88,7 @@ class TestUploads:
|
|||
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"
|
||||
assert response == ResponseStatus.SUCCEEDED
|
||||
|
||||
def test_get_library_upload_album(self, config, yt_oauth):
|
||||
album = yt_oauth.get_library_upload_album(config["uploads"]["private_album_id"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue