@@ -112,6 +112,7 @@ def test_hit_test_decodes_sql_metadata_and_preserves_image_description_hit_type(
112112 {
113113 ** paragraph ,
114114 "document_resource_type" : DocumentResourceType .DOCUMENT ,
115+ "document_image_id" : None ,
115116 "similarity" : 0.9 ,
116117 "comprehensive_score" : 0.95 ,
117118 "source_id" : asset_id ,
@@ -137,15 +138,18 @@ def test_hit_test_reports_document_origin_independently_of_vector_type(
137138 knowledge_query .filter .return_value .exists .return_value = True
138139 document_query = MagicMock ()
139140 query_set .side_effect = {Knowledge : knowledge_query , Document : document_query }.get
141+ image_file_id = "00000000-0000-0000-0000-000000000010"
140142 document_query .filter .return_value .values_list .return_value = [
141- ("image-document" , DocumentResourceType .IMAGE ),
142- ("ordinary-document" , DocumentResourceType .DOCUMENT ),
143+ ("image-document" , DocumentResourceType .IMAGE , image_file_id ),
144+ ("ordinary-document" , DocumentResourceType .DOCUMENT , "00000000-0000-0000-0000-000000000011" ),
145+ ("image-without-file" , DocumentResourceType .IMAGE , None ),
143146 ]
144147 paragraphs = [
145148 {"id" : "image-text" , "document_id" : "image-document" },
146149 {"id" : "image-vector" , "document_id" : "image-document" },
147150 {"id" : "ordinary-text" , "document_id" : "ordinary-document" },
148151 {"id" : "ordinary-image" , "document_id" : "ordinary-document" },
152+ {"id" : "image-without-file" , "document_id" : "image-without-file" },
149153 ]
150154 list_paragraph .return_value = paragraphs
151155 get_vector .return_value .hit_test .return_value = [
@@ -156,8 +160,8 @@ def test_hit_test_reports_document_origin_independently_of_vector_type(
156160 }
157161 for paragraph , source_type , unit_type in zip (
158162 paragraphs ,
159- [SourceType .PARAGRAPH , SourceType .IMAGE , SourceType .PARAGRAPH , SourceType .IMAGE ],
160- ["text" , "image" , "text" , "image" ],
163+ [SourceType .PARAGRAPH , SourceType .IMAGE , SourceType .PARAGRAPH , SourceType .IMAGE , SourceType . PARAGRAPH ],
164+ ["text" , "image" , "text" , "image" , "text" ],
161165 )
162166 ]
163167
@@ -179,7 +183,12 @@ def test_hit_test_reports_document_origin_independently_of_vector_type(
179183 DocumentResourceType .IMAGE ,
180184 DocumentResourceType .DOCUMENT ,
181185 DocumentResourceType .DOCUMENT ,
186+ DocumentResourceType .IMAGE ,
182187 ],
183188 )
184- self .assertEqual ([row ["hit_unit_type" ] for row in result ], ["text" , "image" , "text" , "image" ])
185- document_query .filter .return_value .values_list .assert_called_once_with ("id" , "resource_type" )
189+ self .assertEqual ([row ["hit_unit_type" ] for row in result ], ["text" , "image" , "text" , "image" , "text" ])
190+ self .assertEqual ([row ["document_image_id" ] for row in result ], [image_file_id , image_file_id , None , None , None ])
191+ self .assertTrue (all ("source_file_id" not in row and "image_id" not in row for row in result ))
192+ document_query .filter .return_value .values_list .assert_called_once_with (
193+ "id" , "resource_type" , "meta__source_file_id"
194+ )
0 commit comments