@@ -280,7 +280,7 @@ def test_process_chunks_batch_multiple_entities(
280280            assert  mock_create_chunks .call_count  ==  3 
281281            mock_bulk_save .assert_called_once ()
282282            bulk_save_args  =  mock_bulk_save .call_args [0 ][0 ]
283-             assert  len (bulk_save_args ) ==  2 
283+             assert  len (bulk_save_args ) ==  6 
284284
285285    @patch ("apps.ai.common.base.chunk_command.ContentType.objects.get_for_model" ) 
286286    @patch ("apps.ai.common.base.chunk_command.Context.objects.filter" ) 
@@ -449,27 +449,25 @@ def test_process_chunks_batch_with_duplicates(
449449        mock_content_type ,
450450        mock_chunks ,
451451    ):
452-         """Test that duplicate chunks  are filtered out before bulk save .""" 
452+         """Test that duplicate chunk texts  are filtered out before processing .""" 
453453        mock_get_content_type .return_value  =  mock_content_type 
454454        mock_context_filter .return_value .first .return_value  =  mock_context 
455-         mock_split_text .return_value  =  ["chunk1" , "chunk2" , "chunk3" ]
455+         mock_split_text .return_value  =  ["chunk1" , "chunk2" , "chunk1"  ,  " chunk3" ,  "chunk2 "
456456        mock_create_chunks .return_value  =  mock_chunks 
457457        command .openai_client  =  Mock ()
458458
459-         with  (
460-             patch ("apps.ai.models.chunk.Chunk.objects.filter" ) as  mock_chunk_filter ,
461-             patch .object (command .stdout , "write" ),
462-         ):
463-             mock_qs  =  Mock ()
464-             mock_qs .values_list .return_value  =  [(1 , "Chunk text 1" )]
465-             mock_chunk_filter .return_value  =  mock_qs 
466- 
459+         with  patch .object (command .stdout , "write" ):
467460            result  =  command .process_chunks_batch ([mock_entity ])
468461
469462            assert  result  ==  1 
470-             mock_bulk_save .assert_called_once ()
471-             bulk_save_args  =  mock_bulk_save .call_args [0 ][0 ]
472-             assert  len (bulk_save_args ) ==  2 
463+             mock_split_text .assert_called_once ()
464+             mock_create_chunks .assert_called_once_with (
465+                 chunk_texts = ["chunk1" , "chunk2" , "chunk3" ],
466+                 context = mock_context ,
467+                 openai_client = command .openai_client ,
468+                 save = False ,
469+             )
470+             mock_bulk_save .assert_called_once_with (mock_chunks )
473471
474472    def  test_process_chunks_batch_whitespace_only_content (
475473        self , command , mock_entity , mock_context , mock_content_type 
0 commit comments