forked from MarcinKorcz101/mk-ai-agents
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for missing OpenRouter API key
- Loading branch information
Mateusz Stawicki
committed
Oct 28, 2024
1 parent
fcc14c8
commit dfde2ee
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |