@@ -55,7 +55,7 @@ def mock_api_client(vertexai=False):
5555
5656
5757@pytest .fixture
58- def mock_generate_content_invalid_content ():
58+ def mock_generate_content_with_empty_text_part ():
5959 with mock .patch .object (
6060 models .Models , 'generate_content'
6161 ) as mock_generate_content :
@@ -84,7 +84,7 @@ def mock_generate_content_empty_content():
8484
8585
8686@pytest .fixture
87- def mock_generate_content_stream_invalid_content ():
87+ def mock_generate_content_stream_with_empty_text_part ():
8888 with mock .patch .object (
8989 models .Models , 'generate_content_stream'
9090 ) as mock_generate_content :
@@ -95,7 +95,8 @@ def mock_generate_content_stream_invalid_content():
9595 content = types .Content (
9696 role = 'model' ,
9797 parts = [types .Part (text = '' )],
98- )
98+ ),
99+ finish_reason = types .FinishReason .STOP ,
99100 )
100101 ]
101102 )
@@ -481,7 +482,7 @@ def test_history_with_invalid_turns():
481482 assert chat .get_history (curated = True ) == curated_history
482483
483484
484- def test_chat_with_invalid_content ( mock_generate_content_invalid_content ):
485+ def test_chat_with_empty_text_part ( mock_generate_content_with_empty_text_part ):
485486 models_module = models .Models (mock_api_client )
486487 chats_module = chats .Chats (modules = models_module )
487488 chat = chats_module .create (model = 'gemini-2.5-flash' )
@@ -496,7 +497,7 @@ def test_chat_with_invalid_content(mock_generate_content_invalid_content):
496497 ),
497498 ]
498499 assert chat .get_history () == expected_comprehensive_history
499- assert not chat .get_history (curated = True )
500+ assert chat .get_history (curated = True ) == expected_comprehensive_history
500501
501502
502503def test_chat_with_empty_content (mock_generate_content_empty_content ):
@@ -517,8 +518,8 @@ def test_chat_with_empty_content(mock_generate_content_empty_content):
517518 assert not chat .get_history (curated = True )
518519
519520
520- def test_chat_stream_with_invalid_content (
521- mock_generate_content_stream_invalid_content ,
521+ def test_chat_stream_with_empty_text_part (
522+ mock_generate_content_stream_with_empty_text_part ,
522523):
523524 models_module = models .Models (mock_api_client )
524525 chats_module = chats .Chats (modules = models_module )
@@ -536,7 +537,7 @@ def test_chat_stream_with_invalid_content(
536537 ),
537538 ]
538539 assert chat .get_history () == expected_comprehensive_history
539- assert not chat .get_history (curated = True )
540+ assert chat .get_history (curated = True ) == expected_comprehensive_history
540541
541542
542543def test_chat_stream_with_empty_content (
0 commit comments