Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tstadel committed Dec 11, 2024
1 parent b8e45bc commit 0023403
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions integrations/amazon_bedrock/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,28 +319,37 @@ def test_get_model_adapter(model: str, expected_model_adapter: Optional[Type[Bed
)
def test_get_model_adapter_with_model_family(model_family: str, expected_model_adapter: Optional[Type[BedrockModelAdapter]]):
"""
Test that the correct model adapter is returned for a given model
Test that the correct model adapter is returned for a given model model_family
"""
model_adapter = AmazonBedrockGenerator.get_model_adapter(model="arn:123435423", model_family=model_family)
assert model_adapter == expected_model_adapter


def test_get_model_adapter_with_invalid_model_family():
"""
Test that the correct model adapter is returned for a given model
Test that an error is raised when an invalid model_family is provided
"""
with pytest.raises(AmazonBedrockConfigurationError):
AmazonBedrockGenerator.get_model_adapter(model="arn:123435423", model_family="invalid")


def test_get_model_adapter_auto_detect_family_fails():
"""
Test that the correct model adapter is returned for a given model
Test that an error is raised when auto-detection of model_family fails
"""
with pytest.raises(AmazonBedrockConfigurationError):
AmazonBedrockGenerator.get_model_adapter(model="arn:123435423", model_family=None)


def test_get_model_adapter_model_family_over_auto_detection():
"""
Test that the model_family is used over auto-detection
"""
model_adapter = AmazonBedrockGenerator.get_model_adapter(
model="cohere.command-text-v14", model_family="anthropic.claude"
)
assert model_adapter == AnthropicClaudeAdapter


class TestAnthropicClaudeAdapter:
def test_default_init(self) -> None:
Expand Down

0 comments on commit 0023403

Please sign in to comment.