Skip to content

Commit 3384ade

Browse files
author
Sundar Raghavan
committed
fix: integration test issues
1 parent 387f6f2 commit 3384ade

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

tests_integ/code_interpreter/test_agent_core_code_interpreter_custom_identifier.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -334,23 +334,24 @@ def test_session_not_found_error_with_custom_identifier(self):
334334
custom_id = "session-not-found-test"
335335
interpreter = AgentCoreCodeInterpreter(region="us-west-2", identifier=custom_id, auto_create=False)
336336

337-
# Try to execute code in non-existent session
338-
result = interpreter.code_interpreter(
339-
code_interpreter_input={
340-
"action": {
341-
"type": "executeCode",
342-
"session_name": "non-existent-session",
343-
"code": "print('This should fail')",
344-
"language": "python"
337+
# Try to execute code in non-existent session - should raise ValueError
338+
with pytest.raises(ValueError) as exc_info:
339+
interpreter.code_interpreter(
340+
code_interpreter_input={
341+
"action": {
342+
"type": "executeCode",
343+
"session_name": "non-existent-session",
344+
"code": "print('This should fail')",
345+
"language": "python"
346+
}
345347
}
346-
}
347-
)
348+
)
348349

349-
# Verify error response
350-
assert result['status'] == 'error'
351-
error_message = result['content'][0]['text']
350+
# Verify error message contains expected information
351+
error_message = str(exc_info.value)
352352
assert "non-existent-session" in error_message
353353
assert "not found" in error_message
354+
assert "initSession" in error_message
354355

355356
def test_multiple_error_scenarios_with_different_identifiers(self):
356357
"""Test various error scenarios with different custom identifiers."""
@@ -570,19 +571,21 @@ def test_auto_create_flag_behavior(self):
570571
interpreter2 = AgentCoreCodeInterpreter(region="us-west-2", auto_create=False)
571572
assert interpreter2.auto_create == False
572573

573-
# Test strict mode behavior - should fail when session doesn't exist
574-
result = interpreter2.code_interpreter(
575-
code_interpreter_input={
576-
"action": {
577-
"type": "executeCode",
578-
"session_name": "non-existent-session",
579-
"code": "print('This should fail')",
580-
"language": "python"
574+
# Test strict mode behavior - should raise ValueError when session doesn't exist
575+
with pytest.raises(ValueError) as exc_info:
576+
interpreter2.code_interpreter(
577+
code_interpreter_input={
578+
"action": {
579+
"type": "executeCode",
580+
"session_name": "non-existent-session",
581+
"code": "print('This should fail')",
582+
"language": "python"
583+
}
581584
}
582-
}
583-
)
585+
)
584586

585-
assert result['status'] == 'error'
586-
error_message = result['content'][0]['text']
587+
# Verify error message contains expected information
588+
error_message = str(exc_info.value)
589+
assert "non-existent-session" in error_message
587590
assert "not found" in error_message
588-
assert "auto_create" in error_message
591+
assert "initSession" in error_message

0 commit comments

Comments
 (0)