@@ -57,7 +57,7 @@ async def nova_model(model_id, region):
5757 yield model
5858 # Cleanup
5959 if model ._active :
60- await model .close ()
60+ await model .stop ()
6161
6262
6363# Initialization and Connection Tests
@@ -82,14 +82,14 @@ async def test_connection_lifecycle(nova_model, mock_client, mock_stream):
8282 nova_model .client = mock_client
8383
8484 # Test basic connection
85- await nova_model .connect (system_prompt = "Test system prompt" )
85+ await nova_model .start (system_prompt = "Test system prompt" )
8686 assert nova_model ._active
8787 assert nova_model .stream == mock_stream
8888 assert nova_model .connection_id is not None
8989 assert mock_client .invoke_model_with_bidirectional_stream .called
9090
9191 # Test close
92- await nova_model .close ()
92+ await nova_model .stop ()
9393 assert not nova_model ._active
9494 assert mock_stream .input_stream .close .called
9595
@@ -101,10 +101,10 @@ async def test_connection_lifecycle(nova_model, mock_client, mock_stream):
101101 "inputSchema" : {"json" : json .dumps ({"type" : "object" , "properties" : {}})}
102102 }
103103 ]
104- await nova_model .connect (system_prompt = "You are helpful" , tools = tools )
104+ await nova_model .start (system_prompt = "You are helpful" , tools = tools )
105105 # Verify initialization events were sent (connectionStart, promptStart, system prompt)
106106 assert mock_stream .input_stream .send .call_count >= 3
107- await nova_model .close ()
107+ await nova_model .stop ()
108108
109109
110110@pytest .mark .asyncio
@@ -114,15 +114,15 @@ async def test_connection_edge_cases(nova_model, mock_client, mock_stream, model
114114 nova_model .client = mock_client
115115
116116 # Test double connection
117- await nova_model .connect ()
117+ await nova_model .start ()
118118 with pytest .raises (RuntimeError , match = "Connection already active" ):
119- await nova_model .connect ()
120- await nova_model .close ()
119+ await nova_model .start ()
120+ await nova_model .stop ()
121121
122122 # Test close when already closed
123123 model2 = BidiNovaSonicModel (model_id = model_id , region = region )
124- await model2 .close () # Should not raise
125- await model2 .close () # Second call should also be safe
124+ await model2 .stop () # Should not raise
125+ await model2 .stop () # Second call should also be safe
126126
127127
128128# Send Method Tests
@@ -140,7 +140,7 @@ async def test_send_all_content_types(nova_model, mock_client, mock_stream):
140140 with patch .object (nova_model , "_initialize_client" , new_callable = AsyncMock ):
141141 nova_model .client = mock_client
142142
143- await nova_model .connect ()
143+ await nova_model .start ()
144144
145145 # Test text content
146146 text_event = BidiTextInputEvent (text = "Hello, Nova!" , role = "user" )
@@ -171,7 +171,7 @@ async def test_send_all_content_types(nova_model, mock_client, mock_stream):
171171 # Should send contentStart, toolResult, and contentEnd
172172 assert mock_stream .input_stream .send .called
173173
174- await nova_model .close ()
174+ await nova_model .stop ()
175175
176176
177177@pytest .mark .asyncio
@@ -190,7 +190,7 @@ async def test_send_edge_cases(nova_model, mock_client, mock_stream, caplog):
190190 await nova_model .send (text_event ) # Should not raise
191191
192192 # Test image content (not supported, base64 encoded, no encoding parameter)
193- await nova_model .connect ()
193+ await nova_model .start ()
194194 import base64
195195 image_b64 = base64 .b64encode (b"image data" ).decode ('utf-8' )
196196 image_event = BidiImageInputEvent (
@@ -201,7 +201,7 @@ async def test_send_edge_cases(nova_model, mock_client, mock_stream, caplog):
201201 # Should log warning about unsupported image input
202202 assert any ("not supported" in record .message .lower () for record in caplog .records )
203203
204- await nova_model .close ()
204+ await nova_model .stop ()
205205
206206
207207# Receive and Event Conversion Tests
@@ -220,7 +220,7 @@ async def mock_wait_for(*args, **kwargs):
220220 raise asyncio .TimeoutError ()
221221
222222 with patch ("asyncio.wait_for" , side_effect = mock_wait_for ):
223- await nova_model .connect ()
223+ await nova_model .start ()
224224
225225 events = []
226226 async for event in nova_model .receive ():
@@ -333,7 +333,7 @@ async def test_audio_connection_lifecycle(nova_model, mock_client, mock_stream):
333333 with patch .object (nova_model , "_initialize_client" , new_callable = AsyncMock ):
334334 nova_model .client = mock_client
335335
336- await nova_model .connect ()
336+ await nova_model .start ()
337337
338338 # Start audio connection
339339 await nova_model ._start_audio_connection ()
@@ -343,7 +343,7 @@ async def test_audio_connection_lifecycle(nova_model, mock_client, mock_stream):
343343 await nova_model ._end_audio_input ()
344344 assert not nova_model .audio_connection_active
345345
346- await nova_model .close ()
346+ await nova_model .stop ()
347347
348348
349349@pytest .mark .asyncio
@@ -355,7 +355,7 @@ async def test_silence_detection(nova_model, mock_client, mock_stream):
355355 nova_model .client = mock_client
356356 nova_model .silence_threshold = 0.1 # Short threshold for testing
357357
358- await nova_model .connect ()
358+ await nova_model .start ()
359359
360360 # Send audio to start connection (base64 encoded)
361361 import base64
@@ -376,7 +376,7 @@ async def test_silence_detection(nova_model, mock_client, mock_stream):
376376 # Audio connection should be ended
377377 assert not nova_model .audio_connection_active
378378
379- await nova_model .close ()
379+ await nova_model .stop ()
380380
381381
382382# Helper Method Tests
@@ -458,10 +458,10 @@ async def mock_error(*args, **kwargs):
458458
459459 mock_stream .await_output .side_effect = mock_error
460460
461- await nova_model .connect ()
461+ await nova_model .start ()
462462
463463 # Wait a bit for response processor to handle error
464464 await asyncio .sleep (0.1 )
465465
466466 # Should still be able to close cleanly
467- await nova_model .close ()
467+ await nova_model .stop ()
0 commit comments