1414)
1515from mindee .v2 .parsing import InferenceActiveOptions
1616from mindee .v2 .product .extraction .extraction_response import ExtractionResponse
17+ from mindee .v2 .product .split .params .split_parameters import SplitParameters
1718from mindee .v2 .product .split .split_response import SplitResponse
1819from tests .utils import FILE_TYPES_DIR , V2_PRODUCT_DATA_DIR
1920
@@ -170,40 +171,7 @@ def test_parse_file_filled_single_page_must_succeed(
170171
171172@pytest .mark .integration
172173@pytest .mark .v2
173- @pytest .mark .parametrize (
174- ("response_cls" , "input_path" , "model_id" ),
175- [
176- (
177- ExtractionResponse ,
178- V2_PRODUCT_DATA_DIR / "extraction" / "financial_document" / "default_sample.jpg" ,
179- "extraction" ,
180- ),
181- (
182- SplitResponse ,
183- V2_PRODUCT_DATA_DIR / "split" / "default_sample.pdf" ,
184- "split" ,
185- ),
186- ],
187- )
188- def test_enqueue_with_two_webhooks_must_complete_and_succeed (
189- v2_client : Client ,
190- findoc_model_id : str ,
191- split_model_id : str ,
192- response_cls ,
193- input_path : Path ,
194- model_id : str ,
195- ) -> None :
196- webhook_ids = [
197- "a2286ed9-aa11-aa11-bdc5-2f8496c5641a" ,
198- "b2286ed9-aa11-aa11-bdc5-2f8496c5641a" ,
199- ]
200- resolved_model_id = findoc_model_id if model_id == "extraction" else split_model_id
201-
202- input_source = PathInput (input_path )
203- params = ExtractionParameters (model_id = resolved_model_id , webhook_ids = webhook_ids )
204-
205- response = v2_client .enqueue_and_get_result (response_cls , input_source , params )
206-
174+ def _assert_webhook_job_success (response , webhook_ids : list [str ]) -> None :
207175 assert response .inference is not None
208176 assert response .inference .result is not None
209177
@@ -215,11 +183,45 @@ def test_enqueue_with_two_webhooks_must_complete_and_succeed(
215183 assert all (webhook .status in {"Completed" , "Failed" } for webhook in response .job .webhooks )
216184 assert {webhook .id for webhook in response .job .webhooks } == set (webhook_ids )
217185
218- assert response .inference .result is not None
219- if response_cls is ExtractionResponse :
220- assert response .inference .result .fields ["supplier_name" ].value == "John Smith"
221- else :
222- assert len (response .inference .result .splits ) == 2
186+
187+ @pytest .mark .integration
188+ @pytest .mark .v2
189+ def test_extraction_with_two_webhooks_must_complete_and_succeed (
190+ v2_client : Client , findoc_model_id : str
191+ ) -> None :
192+ webhook_ids = [
193+ "-aa11-aa11-bdc5-2f8496c5641aa2286ed9" ,
194+ "b2286ed9-aa11-aa11-bdc5-2f8496c5641a" ,
195+ ]
196+
197+ input_source = PathInput (
198+ V2_PRODUCT_DATA_DIR / "extraction" / "financial_document" / "default_sample.jpg"
199+ )
200+ params = ExtractionParameters (model_id = findoc_model_id , webhook_ids = webhook_ids )
201+
202+ response = v2_client .enqueue_and_get_result (ExtractionResponse , input_source , params )
203+
204+ _assert_webhook_job_success (response , webhook_ids )
205+ assert response .inference .result .fields ["supplier_name" ].value == "John Smith"
206+
207+
208+ @pytest .mark .integration
209+ @pytest .mark .v2
210+ def test_split_with_two_webhooks_must_complete_and_succeed (
211+ v2_client : Client , split_model_id : str
212+ ) -> None :
213+ webhook_ids = [
214+ "a2286ed9-aa11-aa11-bdc5-2f8496c5641a" ,
215+ "b2286ed9-aa11-aa11-bdc5-2f8496c5641a" ,
216+ ]
217+
218+ input_source = PathInput (V2_PRODUCT_DATA_DIR / "split" / "default_sample.pdf" )
219+ params = SplitParameters (model_id = split_model_id , webhook_ids = webhook_ids )
220+
221+ response = v2_client .enqueue_and_get_result (SplitResponse , input_source , params )
222+
223+ _assert_webhook_job_success (response , webhook_ids )
224+ assert len (response .inference .result .splits ) == 2
223225
224226
225227@pytest .mark .integration
0 commit comments