upload_song: add error when file exceeds limit of 300MB (#653)
* upload_song: add error when file exceeds limit of 300MB (closes #647) * fix import
This commit is contained in:
parent
09ca398719
commit
7d8a756638
3 changed files with 14 additions and 1 deletions
|
|
@ -4,7 +4,8 @@ from pathlib import Path
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from test_helpers import is_ci
|
||||
|
||||
from tests.test_helpers import is_ci
|
||||
|
||||
|
||||
class TestBrowsing:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import tempfile
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import get_resource
|
||||
from ytmusicapi.enums import ResponseStatus
|
||||
from ytmusicapi.exceptions import YTMusicUserError
|
||||
from ytmusicapi.ytmusic import YTMusic
|
||||
|
||||
|
||||
|
|
@ -51,6 +53,12 @@ class TestUploads:
|
|||
response = yt_auth.upload_song(get_resource(config["uploads"]["file"]))
|
||||
assert response.status_code == 409
|
||||
|
||||
with (
|
||||
mock.patch("os.path.getsize", return_value=4 * 10**9),
|
||||
pytest.raises(YTMusicUserError, match="larger than the limit of 300MB"),
|
||||
):
|
||||
yt_auth.upload_song(get_resource(config["uploads"]["file"]))
|
||||
|
||||
def test_upload_song_and_verify(self, config, yt_auth: YTMusic):
|
||||
"""Upload a song and verify it can be retrieved after it finishes processing."""
|
||||
upload_response = yt_auth.upload_song(get_resource(config["uploads"]["file"]))
|
||||
|
|
|
|||
Loading…
Reference in a new issue