]> littlesong.place Git - littlesongplace.git/commitdiff
Add marker and argument for youtube importer tests
authorChris Fulljames <christianfulljames@gmail.com>
Sun, 6 Apr 2025 13:44:20 +0000 (09:44 -0400)
committerChris Fulljames <christianfulljames@gmail.com>
Sun, 6 Apr 2025 13:44:20 +0000 (09:44 -0400)
pyproject.toml
test/conftest.py
test/test_online.py
test/test_songs.py

index 7304c26f032458bc1fedaad1190fe62827f6e9f8..d7ccbe2d288769a4f50c5fae9cfccd332b2207a2 100644 (file)
@@ -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",
+]
index 182550b9d645aee08e1f363ed9ee8f7aca33f81a..1d7428da881a8fa3ad2de0e486c4da36b961aeb1 100644 (file)
@@ -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)
+
index 350256235d18511eeceadeb81f0dc7bbb8c5efdd..9672f74cc9ed44bac861875ef754d8ad2706f2f9 100644 (file)
@@ -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!@#$")
 
index d06fcb7aef23d1ac658f845a320cb638c69ae8ed..dc508a0252fe2e3ff617ba1414edf499ef5f7e74 100644 (file)
@@ -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 &#39;song title&#39;", 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 = {