Skip to content

Commit

Permalink
Add freezegun
Browse files Browse the repository at this point in the history
Having trouble getting yt-dlp invocations to work nicely with vcrpy,
suspect this is due to it receiving responses that are time-limited

Affected tests:
- tests/utils/test_ffmpeg.py::test_convert
- tests/utils/test_metadata.py::test_embed_metadata
  • Loading branch information
hseg committed Aug 28, 2024
1 parent 44cc82e commit 1f7704e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
32 changes: 31 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mkdocs-section-index = "^0.3.5"
vcrpy = "^6.0.1"
pytest-recording = "^0.13.1"
pytest-vcr-delete-on-fail = {version = "^2.0.1", python = "^3.8.1"}
pytest-freezegun = "^0.4.2"

[tool.poetry.scripts]
spotdl = "spotdl:console_entry_point"
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path

import pytest
from freezegun import freeze_time

from spotdl.download.downloader import Downloader
from spotdl.utils import ffmpeg
Expand All @@ -18,6 +19,12 @@
init_logging("MATCH")


@pytest.fixture
def last_vcr_recording_time():
with freeze_time("2024-08-27 22:00:00", tz_offset=-3):
yield


class FakeProcess:
"""Instead of running ffmpeg, just fake it"""

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_download_ffmpeg(monkeypatch, tmpdir):

@pytest.mark.vcr()
@pytest.mark.vcr_delete_on_fail
def test_convert(tmpdir, monkeypatch):
def test_convert(tmpdir, monkeypatch, last_vcr_recording_time):
"""
Test convert function.
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
)
@pytest.mark.vcr()
@pytest.mark.vcr_delete_on_fail
def test_embed_metadata(tmpdir, monkeypatch, output_format):
def test_embed_metadata(tmpdir, monkeypatch, last_vcr_recording_time,
output_format):

"""
Test convert function.
"""
Expand Down

0 comments on commit 1f7704e

Please sign in to comment.