From f1515e88cb0984fe2cca2821fad76db10d9b8d2a Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Tue, 25 Jun 2024 22:27:45 +0530 Subject: [PATCH] skip tests if env var missing --- glossary_resources/tests.py | 2 ++ tests/test_checkout.py | 2 ++ tests/test_slack.py | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/glossary_resources/tests.py b/glossary_resources/tests.py index d28650f45..362e3c759 100644 --- a/glossary_resources/tests.py +++ b/glossary_resources/tests.py @@ -1,6 +1,7 @@ import pytest from daras_ai.image_input import storage_blob_for +from daras_ai_v2 import settings from daras_ai_v2.crypto import get_random_doc_id from glossary_resources.models import GlossaryResource from tests.test_translation import _test_run_google_translate_one @@ -62,6 +63,7 @@ def glossary_url(): GlossaryResource.objects.all().delete() +@pytest.mark.skipif(not settings.GS_BUCKET_NAME, reason="No GCS bucket") @pytest.mark.django_db def test_run_google_translate_glossary(glossary_url, threadpool_subtest): for text, expected, expected_with_glossary in TRANSLATION_TESTS_GLOSSARY: diff --git a/tests/test_checkout.py b/tests/test_checkout.py index 06695ae1b..e7610ba50 100644 --- a/tests/test_checkout.py +++ b/tests/test_checkout.py @@ -2,6 +2,7 @@ from fastapi.testclient import TestClient from app_users.models import AppUser +from daras_ai_v2 import settings from daras_ai_v2.billing import create_stripe_checkout_session from gooey_ui import RedirectException from payments.plans import PricingPlan @@ -10,6 +11,7 @@ client = TestClient(app) +@pytest.mark.skipif(not settings.STRIPE_ENDPOINT_SECRET, reason="No stripe secret") @pytest.mark.parametrize("plan", PricingPlan) def test_create_checkout_session( plan: PricingPlan, transactional_db, force_authentication: AppUser diff --git a/tests/test_slack.py b/tests/test_slack.py index 3a5802c8d..df1b9ce05 100644 --- a/tests/test_slack.py +++ b/tests/test_slack.py @@ -1,3 +1,4 @@ +import pytest from decouple import config from starlette.testclient import TestClient @@ -12,6 +13,9 @@ def test_slack_safe_channel_name(): assert safe_channel_name("My, Awesome, Channel %") == "my-awesome-channel" +@pytest.mark.skipif( + not config("TEST_SLACK_TEAM_ID", None), reason="No test slack team id" +) def test_slack_get_response_for_msg_id(transactional_db): team_id = config("TEST_SLACK_TEAM_ID") user_id = config("TEST_SLACK_USER_ID")