Skip to content

Commit

Permalink
fix size mock
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Oct 5, 2024
1 parent 0868e2f commit 0562503
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/mixins/test_uploads.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import stat
import tempfile
import time
from unittest import mock
Expand Down Expand Up @@ -53,8 +55,16 @@ def test_upload_song(self, config, yt_auth):
response = yt_auth.upload_song(get_resource(config["uploads"]["file"]))
assert response.status_code == 409

def test_upload_song_file_too_large(self, config, yt_auth):
orig_os_stat = os.stat

def fake_stat(arg, **kwargs):
faked = list(orig_os_stat(arg))
faked[stat.ST_SIZE] = 4 * 10**9
return os.stat_result(faked)

with (
mock.patch("os.path.getsize", return_value=4 * 10**9),
mock.patch("os.stat", side_effect=fake_stat),
pytest.raises(YTMusicUserError, match="larger than the limit of 300MB"),
):
yt_auth.upload_song(get_resource(config["uploads"]["file"]))
Expand Down

0 comments on commit 0562503

Please sign in to comment.