Skip to content

Commit

Permalink
Add fixture to load API keys from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hmasdev committed Sep 7, 2024
1 parent 178e4b1 commit ac34675
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}


@pytest.mark.usefixtures('api_keys')
@pytest.mark.parametrize(
'llm, expected',
[(k, v) for _, (k, v) in enumerate(name2cls.items())]
Expand All @@ -30,6 +31,7 @@ def test_create_chat_model_wo_seed(
assert isinstance(create_chat_model(llm), expected)


@pytest.mark.usefixtures('api_keys')
@pytest.mark.parametrize(
'llm, seed, expected',
[(k, i, v) for i, (k, v) in enumerate(name2cls.items())]
Expand All @@ -52,6 +54,7 @@ def test_create_chat_model_w_invalid_llm() -> None:
create_chat_model('invalid')


@pytest.mark.usefixtures('api_keys')
@pytest.mark.integration
@pytest.mark.skipif(
os.getenv("OPENAI_API_KEY") is None,
Expand All @@ -71,6 +74,7 @@ def test_create_chat_model_for_ChatOpenAI_integration(llm: str) -> None:
assert isinstance(create_chat_model(llm), ChatOpenAI)


@pytest.mark.usefixtures('api_keys')
@pytest.mark.integration
@pytest.mark.skipif(
os.getenv("GROQ_API_KEY") is None,
Expand All @@ -96,6 +100,7 @@ def test_create_chat_model_for_ChatGroq_integration(llm: str) -> None:
assert isinstance(create_chat_model(llm), ChatGroq)


@pytest.mark.usefixtures('api_keys')
@pytest.mark.integration
@pytest.mark.skipif(
os.getenv("GOOGLE_API_KEY") is None,
Expand Down

0 comments on commit ac34675

Please sign in to comment.