From 51a56af7cabafea56eece5d34e3895b1a73362eb Mon Sep 17 00:00:00 2001 From: Debanjum Date: Wed, 25 Mar 2026 18:08:07 +0530 Subject: [PATCH] Skip automation tests when GEMINI_API_KEY is not set - Add missing skipif decorator to test_create_automation - Change skip condition from 'is None' to 'not' (falsy check) to also handle empty string, which happens when GitHub secrets are unavailable in fork PRs --- tests/test_api_automation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_api_automation.py b/tests/test_api_automation.py index b05d0e63..5b02612d 100644 --- a/tests/test_api_automation.py +++ b/tests/test_api_automation.py @@ -32,6 +32,7 @@ def create_test_automation(client: TestClient) -> str: @pytest.mark.django_db(transaction=True) +@pytest.mark.skipif(not get_chat_api_key("google"), reason="Requires GEMINI_API_KEY to be set") def test_create_automation(client: TestClient): """Test that creating an automation works as expected.""" # Arrange @@ -55,7 +56,7 @@ def test_create_automation(client: TestClient): @pytest.mark.django_db(transaction=True) -@pytest.mark.skipif(get_chat_api_key("google") is None, reason="Requires GEMINI_API_KEY to be set") +@pytest.mark.skipif(not get_chat_api_key("google"), reason="Requires GEMINI_API_KEY to be set") def test_get_automations(client: TestClient): """Test that getting a list of automations works.""" automation_id = create_test_automation(client) @@ -72,7 +73,7 @@ def test_get_automations(client: TestClient): @pytest.mark.django_db(transaction=True) -@pytest.mark.skipif(get_chat_api_key("google") is None, reason="Requires GEMINI_API_KEY to be set") +@pytest.mark.skipif(not get_chat_api_key("google"), reason="Requires GEMINI_API_KEY to be set") def test_delete_automation(client: TestClient): """Test that deleting an automation works.""" automation_id = create_test_automation(client) @@ -91,7 +92,7 @@ def test_delete_automation(client: TestClient): @pytest.mark.django_db(transaction=True) -@pytest.mark.skipif(get_chat_api_key("google") is None, reason="Requires GEMINI_API_KEY to be set") +@pytest.mark.skipif(not get_chat_api_key("google"), reason="Requires GEMINI_API_KEY to be set") def test_edit_automation(client: TestClient): """Test that editing an automation works.""" automation_id = create_test_automation(client) @@ -118,7 +119,7 @@ def test_edit_automation(client: TestClient): @pytest.mark.django_db(transaction=True) -@pytest.mark.skipif(get_chat_api_key("google") is None, reason="Requires GEMINI_API_KEY to be set") +@pytest.mark.skipif(not get_chat_api_key("google"), reason="Requires GEMINI_API_KEY to be set") def test_trigger_automation(client: TestClient): """Test that triggering an automation works.""" automation_id = create_test_automation(client)