Skip to content

Commit

Permalink
Add test for missing OpenRouter API key
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Stawicki committed Oct 28, 2024
1 parent fcc14c8 commit dfde2ee
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_game/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import pytest
import importlib
from unittest import mock

import llm_postor.config # Import initially

@pytest.fixture
def clear_env():
"""Clear specific environment variables for testing."""
with mock.patch.dict(os.environ, {"OPENROUTER_API_KEY": ""}):
yield

def test_missing_openrouter_api_key(clear_env):
# Reload the module to re-evaluate with the cleared environment variable
with pytest.raises(ValueError, match="API key is missing"):
importlib.reload(llm_postor.config)

0 comments on commit dfde2ee

Please sign in to comment.