|
8 | 8 | import pytest |
9 | 9 | from models_library.projects_state import RunningState |
10 | 10 | from pydantic.main import BaseModel |
| 11 | +from pytest_simcore.pydantic_models import ( |
| 12 | + assert_validation_model, |
| 13 | + iter_model_examples_in_class, |
| 14 | +) |
11 | 15 | from simcore_service_director_v2.models.comp_runs import CompRunsAtDB |
12 | 16 |
|
13 | 17 |
|
14 | 18 | @pytest.mark.parametrize( |
15 | | - "model_cls", |
16 | | - [ |
17 | | - CompRunsAtDB, |
18 | | - ], |
| 19 | + "model_cls, example_name, example_data", |
| 20 | + iter_model_examples_in_class(CompRunsAtDB), |
19 | 21 | ) |
20 | 22 | def test_computation_run_model_examples( |
21 | | - model_cls: type[BaseModel], model_cls_examples: dict[str, dict[str, Any]] |
| 23 | + model_cls: type[BaseModel], example_name: str, example_data: dict[str, Any] |
22 | 24 | ): |
23 | | - for name, example in model_cls_examples.items(): |
24 | | - print(name, ":", pformat(example)) |
25 | | - model_instance = model_cls(**example) |
26 | | - assert model_instance, f"Failed with {name}" |
| 25 | + assert_validation_model( |
| 26 | + model_cls, example_name=example_name, example_data=example_data |
| 27 | + ) |
27 | 28 |
|
28 | 29 |
|
29 | 30 | @pytest.mark.parametrize( |
30 | | - "model_cls", |
31 | | - [ |
32 | | - CompRunsAtDB, |
33 | | - ], |
| 31 | + "model_cls, example_name, example_data", |
| 32 | + iter_model_examples_in_class(CompRunsAtDB), |
34 | 33 | ) |
35 | 34 | def test_computation_run_model_with_run_result_value_field( |
36 | | - model_cls: type[BaseModel], model_cls_examples: dict[str, dict[str, Any]] |
| 35 | + model_cls: type[BaseModel], example_name: str, example_data: dict[str, Any] |
37 | 36 | ): |
38 | | - for name, example in model_cls_examples.items(): |
39 | | - example["result"] = RunningState.WAITING_FOR_RESOURCES.value |
40 | | - print(name, ":", pformat(example)) |
41 | | - model_instance = model_cls(**example) |
42 | | - assert model_instance, f"Failed with {name}" |
| 37 | + example_data["result"] = RunningState.WAITING_FOR_RESOURCES.value |
| 38 | + print(example_name, ":", pformat(example_data)) |
| 39 | + model_instance = model_cls(**example_data) |
| 40 | + assert model_instance, f"Failed with {example_name}" |
0 commit comments