diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0b71cd3 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,18 @@ +import os + +import pytest + +REQUIRED_SECRETS = "RUN_TESTS_WITH_SECRETS" + + +def pytest_collection_modifyitems(config, items): + if os.getenv(REQUIRED_SECRETS): + return + + skip_marker = pytest.mark.skip( + reason=f"Excluding tests with secrets (no : {REQUIRED_SECRETS} found)" + ) + + for item in items: + if "secrets" in item.keywords: + item.add_marker(skip_marker) diff --git a/tests/test_dropbox_.py b/tests/test_dropbox_.py index 800cd98..9493199 100644 --- a/tests/test_dropbox_.py +++ b/tests/test_dropbox_.py @@ -1,12 +1,16 @@ +import pytest + from pauperformance_bot.service.pauperformance.storage.dropbox_ import DropboxService +@pytest.mark.secrets def test_list_imported_youtube_videos(): assert any( "Pauperformance" in v for v in DropboxService().list_imported_youtube_videos() ) +@pytest.mark.secrets def test_list_imported_mtggoldfish_deck_names(): assert any( "Jund" in d for d in DropboxService().list_imported_mtggoldfish_deck_names() diff --git a/tox.ini b/tox.ini index 6aa9f3d..af1a7e0 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,8 @@ commands = python setup.py sdist [pytest] +markers = + secrets: tests that require secrets addopts = --cov pauperformance_bot --cov pauperformance_bot