1
1
import pytest
2
2
3
3
from cognite .client ._cognite_client import CogniteClient
4
- from cognite .client .data_classes .simulators .runs import (
5
- SimulationRunWrite ,
6
- )
4
+ from cognite .client .data_classes .simulators .runs import SimulationRunWrite , SimulatorRunsList
5
+
6
+
7
+ def create_simulation_run (
8
+ cognite_client : CogniteClient ,
9
+ routine_external_id : str ,
10
+ ) -> SimulatorRunsList :
11
+ return cognite_client .simulators .runs .create (
12
+ [
13
+ SimulationRunWrite (
14
+ run_type = "external" ,
15
+ routine_external_id = routine_external_id ,
16
+ )
17
+ ]
18
+ )
7
19
8
20
9
21
@pytest .mark .usefixtures ("seed_resource_names" , "seed_simulator_routine_revisions" )
@@ -12,13 +24,9 @@ def test_create_run(
12
24
self , cognite_client : CogniteClient , seed_simulator_routine_revisions , seed_resource_names
13
25
) -> None :
14
26
routine_external_id = seed_resource_names ["simulator_routine_external_id" ]
15
- created_runs = cognite_client .simulators .runs .create (
16
- [
17
- SimulationRunWrite (
18
- run_type = "external" ,
19
- routine_external_id = routine_external_id ,
20
- )
21
- ]
27
+ created_runs = create_simulation_run (
28
+ cognite_client = cognite_client ,
29
+ routine_external_id = routine_external_id ,
22
30
)
23
31
assert created_runs [0 ].routine_external_id == routine_external_id
24
32
assert created_runs [0 ].id is not None
@@ -27,13 +35,9 @@ def test_list_filtering(self, cognite_client: CogniteClient, seed_resource_names
27
35
routine_external_id = seed_resource_names ["simulator_routine_external_id" ]
28
36
status = ["running" , "success" , "failure" ]
29
37
for _ in range (3 ):
30
- created_runs = cognite_client .simulators .runs .create (
31
- [
32
- SimulationRunWrite (
33
- run_type = "external" ,
34
- routine_external_id = routine_external_id ,
35
- )
36
- ]
38
+ created_runs = create_simulation_run (
39
+ cognite_client = cognite_client ,
40
+ routine_external_id = routine_external_id ,
37
41
)
38
42
assert created_runs [0 ].routine_external_id == routine_external_id
39
43
status_to_be_set = status .pop (0 )
0 commit comments