From e573f5a7f6c20bc7c65af03b5e7c406c2441d992 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Sun, 6 Apr 2025 09:44:20 -0400 Subject: [PATCH] Add marker and argument for youtube importer tests --- pyproject.toml | 4 ++++ test/conftest.py | 10 ++++++++++ test/test_online.py | 2 +- test/test_songs.py | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7304c26..d7ccbe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,7 @@ requires-python = ">=3.11" requires = ["setuptools >= 77.0.3"] build-backend = "setuptools.build_meta" +[tool.pytest.ini_options] +markers = [ + "yt: mark youtube importer tests", +] diff --git a/test/conftest.py b/test/conftest.py index 182550b..1d7428d 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -55,3 +55,13 @@ def session(): login(session, "user", "1234asdf!@#$") yield session +def pytest_addoption(parser): + parser.addoption("--yt", action="store_true", help="run youtube importer tests") + +def pytest_collection_modifyitems(config, items): + if not config.option.yt: + removed_items = [i for i in items if "yt" in i.keywords] + for ri in removed_items: + items.remove(ri) + config.hook.pytest_deselected(items=removed_items) + diff --git a/test/test_online.py b/test/test_online.py index 3502562..9672f74 100644 --- a/test/test_online.py +++ b/test/test_online.py @@ -85,7 +85,7 @@ def test_comments_and_activity(session): songs = _get_song_list_from_page(response.text) assert not any(song["songid"] == songid for song in songs) -@pytest.mark.skip +@pytest.mark.yt def test_upload_song_from_youtube(session): login(session, "user", "1234asdf!@#$") diff --git a/test/test_songs.py b/test/test_songs.py index d06fcb7..dc508a0 100644 --- a/test/test_songs.py +++ b/test/test_songs.py @@ -68,7 +68,7 @@ def test_upload_song_from_mp4(mock_run, client): create_user(client, "user", "password", login=True) upload_song(client, b"Successfully uploaded 'song title'", filename=TEST_DATA/"sample-4s.mp4") -@pytest.mark.skip +@pytest.mark.yt def test_upload_song_from_youtube(client): create_user(client, "user", "password", login=True) data = { @@ -113,7 +113,7 @@ def test_update_song_success(client): with open(TEST_DATA/"sample-6s.mp3", "rb") as expected_file: assert response.data == expected_file.read() -@pytest.mark.skip +@pytest.mark.yt def test_update_song_from_youtube(client): create_user_and_song(client) data = { -- 2.39.5