Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
brnaba-aws committed Oct 15, 2024
1 parent 5eec25c commit 709a2b8
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions python/src/tests/agents/test_amazon_bedrock_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@ async def test_process_request_error(bedrock_agent):
'invoke_agent'
))

result = await bedrock_agent.process_request(
input_text="Test input",
user_id="test_user",
session_id="test_session",
chat_history=[]
)

assert isinstance(result, ConversationMessage)
assert result.role == ParticipantRole.ASSISTANT.value
assert result.content == [{"text": "Sorry, I encountered an error while processing your request."}]
try:
result = await bedrock_agent.process_request(
input_text="Test input",
user_id="test_user",
session_id="test_session",
chat_history=[]
)
except Exception as error:
assert isinstance(error, ClientError)
assert error.response['Error']['Code'] == 'TestException'
assert error.response['Error']['Message'] == 'Test error'
pass

# Optionally, you can assert that the invoke_agent method was called
bedrock_agent.client.invoke_agent.assert_called_once()

@pytest.mark.asyncio
async def test_process_request_empty_chunk(bedrock_agent):
Expand Down

0 comments on commit 709a2b8

Please sign in to comment.