|
35 | 35 | ModelOutput,
|
36 | 36 | PostProcessInput,
|
37 | 37 | )
|
38 |
| -from ansys.simai.core.errors import InvalidArguments, ProcessingError |
| 38 | +from ansys.simai.core.errors import ApiClientError, InvalidArguments, ProcessingError |
39 | 39 |
|
40 | 40 | if TYPE_CHECKING:
|
41 | 41 | from ansys.simai.core.data.models import Model
|
@@ -584,3 +584,67 @@ def test_post_process_input(simai_client):
|
584 | 584 | build_model.fields["configuration"]["fields"]["surface_pp_input"]
|
585 | 585 | == model_conf_dict["fields"]["surface_pp_input"]
|
586 | 586 | )
|
| 587 | + |
| 588 | + |
| 589 | +@responses.activate |
| 590 | +def test_failed_build_with_resolution(simai_client): |
| 591 | + """WHEN I call launch_build() with using a new build configuration |
| 592 | + THEN I get a Model object, its project_id matches the |
| 593 | + id of the project, and its configuration is a |
| 594 | + ModelConfiguration and its content matches the raw conf. |
| 595 | + """ |
| 596 | + |
| 597 | + raw_project = { |
| 598 | + "id": MODEL_RAW["project_id"], |
| 599 | + "name": "fifi", |
| 600 | + "sample": SAMPLE_RAW, |
| 601 | + } |
| 602 | + |
| 603 | + responses.add( |
| 604 | + responses.GET, |
| 605 | + f"https://test.test/projects/{MODEL_RAW['project_id']}", |
| 606 | + json=raw_project, |
| 607 | + status=200, |
| 608 | + ) |
| 609 | + |
| 610 | + project: Project = simai_client._project_directory._model_from(raw_project) |
| 611 | + |
| 612 | + lgth = ("relative_to_max", 5, 8.1) |
| 613 | + wdth = ("relative_to_max", 5, 8.1) |
| 614 | + hght = ("absolute", -4.5, 0.1) |
| 615 | + |
| 616 | + doa = DomainOfAnalysis( |
| 617 | + length=lgth, |
| 618 | + width=wdth, |
| 619 | + height=hght, |
| 620 | + ) |
| 621 | + |
| 622 | + new_conf = ModelConfiguration( |
| 623 | + project=project, |
| 624 | + build_preset="debug", |
| 625 | + domain_of_analysis=doa, |
| 626 | + ) |
| 627 | + response_json = { |
| 628 | + "status": "Conflict", |
| 629 | + "errors": { |
| 630 | + "fields_discrepancies": [ |
| 631 | + { |
| 632 | + "id": "2a324", |
| 633 | + "name": "td-987", |
| 634 | + "message": "Missing fields: p (volume), p_rgh (volume)", |
| 635 | + } |
| 636 | + ] |
| 637 | + }, |
| 638 | + "resolution": "This is a resolution.", |
| 639 | + } |
| 640 | + |
| 641 | + responses.add( |
| 642 | + responses.POST, |
| 643 | + f"https://test.test/projects/{MODEL_RAW['project_id']}/model", |
| 644 | + json=response_json, |
| 645 | + status=409, |
| 646 | + ) |
| 647 | + |
| 648 | + with pytest.raises(ApiClientError) as e: |
| 649 | + simai_client.models.build(new_conf) |
| 650 | + assert "This is a resolution." in str(e.value) |
0 commit comments