diff --git a/poetry.lock b/poetry.lock index fb00f0b08..45d331fe5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -681,6 +681,20 @@ typing-extensions = ">=4.5.0" [package.extras] all = ["email-validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.5)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +[[package]] +name = "freezegun" +version = "1.5.1" +description = "Let your Python tests travel through time" +optional = false +python-versions = ">=3.7" +files = [ + {file = "freezegun-1.5.1-py3-none-any.whl", hash = "sha256:bf111d7138a8abe55ab48a71755673dbaa4ab87f4cff5634a4442dfec34c15f1"}, + {file = "freezegun-1.5.1.tar.gz", hash = "sha256:b29dedfcda6d5e8e083ce71b2b542753ad48cfec44037b3fc79702e2980a89e9"}, +] + +[package.dependencies] +python-dateutil = ">=2.7" + [[package]] name = "ghp-import" version = "2.1.0" @@ -1888,6 +1902,21 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] +[[package]] +name = "pytest-freezegun" +version = "0.4.2" +description = "Wrap tests with fixtures in freeze_time" +optional = false +python-versions = "*" +files = [ + {file = "pytest-freezegun-0.4.2.zip", hash = "sha256:19c82d5633751bf3ec92caa481fb5cffaac1787bd485f0df6436fd6242176949"}, + {file = "pytest_freezegun-0.4.2-py2.py3-none-any.whl", hash = "sha256:5318a6bfb8ba4b709c8471c94d0033113877b3ee02da5bfcd917c1889cde99a7"}, +] + +[package.dependencies] +freezegun = ">0.3" +pytest = ">=3.0.0" + [[package]] name = "pytest-mock" version = "3.14.0" @@ -2717,6 +2746,7 @@ description = "Automatically mock your HTTP interactions to simplify and speed u optional = false python-versions = ">=3.8" files = [ + {file = "vcrpy-6.0.1-py2.py3-none-any.whl", hash = "sha256:621c3fb2d6bd8aa9f87532c688e4575bcbbde0c0afeb5ebdb7e14cac409edfdd"}, {file = "vcrpy-6.0.1.tar.gz", hash = "sha256:9e023fee7f892baa0bbda2f7da7c8ac51165c1c6e38ff8688683a12a4bde9278"}, ] @@ -3155,4 +3185,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.13" -content-hash = "cefeb4724cab51f40a8ac50c20ba6fe820fe8166cde16506737e2c2e60facd37" +content-hash = "2692fc1c4e7a60a0a4fbb0670469aa3e546c01b182a5cb5e8c9a2fb52ad9b10a" diff --git a/pyproject.toml b/pyproject.toml index ceb9a5ec0..b3106d09d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tests/conftest.py b/tests/conftest.py index 4cdd3204a..7311bf5f5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 @@ -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""" diff --git a/tests/utils/test_ffmpeg.py b/tests/utils/test_ffmpeg.py index 98c543193..1a709a3ff 100644 --- a/tests/utils/test_ffmpeg.py +++ b/tests/utils/test_ffmpeg.py @@ -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. """ diff --git a/tests/utils/test_metadata.py b/tests/utils/test_metadata.py index ae7c4ef13..b8f8434fa 100644 --- a/tests/utils/test_metadata.py +++ b/tests/utils/test_metadata.py @@ -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. """