@@ -23,8 +23,8 @@ def test_create_run(
23
23
24
24
def test_list_filtering (self , cognite_client : CogniteClient , seed_resource_names ) -> None :
25
25
routine_external_id = seed_resource_names ["simulator_routine_external_id" ]
26
- status = ["running" , "success" , "failure" ]
27
- for _ in range ( 3 ) :
26
+ runs_filtered_by_status = []
27
+ for current_status in [ "running" , "success" , "failure" ] :
28
28
created_runs = cognite_client .simulators .runs .create (
29
29
[
30
30
SimulationRunWrite (
@@ -33,26 +33,24 @@ def test_list_filtering(self, cognite_client: CogniteClient, seed_resource_names
33
33
)
34
34
]
35
35
)
36
- assert created_runs [0 ].routine_external_id == routine_external_id
37
- status_to_be_set = status .pop (0 )
38
36
39
37
cognite_client .simulators ._post (
40
38
"/simulators/run/callback" ,
41
39
json = {
42
40
"items" : [
43
41
{
44
42
"id" : created_runs [0 ].id ,
45
- "status" : status_to_be_set ,
43
+ "status" : current_status ,
46
44
}
47
45
]
48
46
},
49
47
)
50
48
51
49
filter_by_status = cognite_client .simulators .runs .list (
52
- status = status_to_be_set , routine_external_ids = [routine_external_id ]
50
+ status = current_status , routine_external_ids = [routine_external_id ]
53
51
)
54
- assert filter_by_status [0 ].status == status_to_be_set
55
- assert filter_by_status [0 ].id == created_runs [0 ].id
52
+ runs_filtered_by_status .append (filter_by_status [0 ].dump ())
56
53
57
- filter_by_routine = cognite_client .simulators .runs .list (routine_external_ids = [routine_external_id ])
58
- assert len (filter_by_routine ) >= 3
54
+ filter_by_routine = cognite_client .simulators .runs .list (routine_external_ids = [routine_external_id ]).dump ()
55
+ for run in runs_filtered_by_status :
56
+ assert run in filter_by_routine
0 commit comments