@@ -76,7 +76,7 @@ def _handle_query_error(
76
76
query_timestamps = [q .request .timestamp for q in e .queries ],
77
77
)
78
78
79
- def _handle_query_result (
79
+ def handle_query_result (
80
80
self ,
81
81
check : PendingCheck ,
82
82
q : RIDQuery ,
@@ -86,7 +86,23 @@ def _handle_query_result(
86
86
fail_details : Optional [str ] = None ,
87
87
):
88
88
"""
89
- :param required_status_code: one of those status code is expected, overrides the success check
89
+ Handle the result of the query, based on the expected result codes versus the actual one,
90
+ and fail the specified check accordingly if the query's HTTP response code is not a success or, if specified,
91
+ it is not present in `required_status_code`.
92
+
93
+ Note that this won't check anything about the response payloads: this is left to the discretion of the caller.
94
+
95
+ The passed query will be properly recorded in the scenario and in case of check failure, its timestamp will
96
+ be associated with the check.
97
+
98
+ Additionally, upon failure, the participant_id of the underlying DSS is set as the check's participants.
99
+
100
+ :param check: the check to fail if q is not successful (or, when applicable, its response code is not in required_status_code)
101
+ :param q: the query to check
102
+ :param fail_msg: the message to use when failing the check
103
+ :param required_status_code: the set of status codes that are considered successful. If this is None then success is defined by `q.success`
104
+ :param severity: the severity of the check failure
105
+ :param fail_details: the details passed to check.record_fail
90
106
"""
91
107
self ._scenario .record_query (q .query )
92
108
if (required_status_code is None and not q .success ) or (
@@ -127,7 +143,7 @@ def search_isas(
127
143
session = self ._dss .client ,
128
144
participant_id = self ._dss .participant_id ,
129
145
)
130
- self ._handle_query_result (
146
+ self .handle_query_result (
131
147
main_check ,
132
148
isas ,
133
149
f"Failed to search ISAs in { area } from { start_time } to { end_time } " ,
@@ -178,7 +194,7 @@ def search_isas_expect_response_code(
178
194
participant_id = self ._dss .participant_id ,
179
195
)
180
196
181
- self ._handle_query_result (
197
+ self .handle_query_result (
182
198
check = main_check ,
183
199
q = isas ,
184
200
required_status_code = expected_error_codes ,
@@ -208,7 +224,7 @@ def get_isa(
208
224
participant_id = self ._dss .participant_id ,
209
225
)
210
226
211
- self ._handle_query_result (check , isa , f"Failed to get ISA { isa_id } " )
227
+ self .handle_query_result (check , isa , f"Failed to get ISA { isa_id } " )
212
228
213
229
if isa_id != isa .isa .id :
214
230
check .record_failed (
@@ -247,7 +263,7 @@ def get_isa_expect_response_code(
247
263
participant_id = self ._dss .participant_id ,
248
264
)
249
265
250
- self ._handle_query_result (
266
+ self .handle_query_result (
251
267
check = check ,
252
268
q = isa ,
253
269
required_status_code = expected_error_codes ,
@@ -284,7 +300,7 @@ def put_isa_expect_response_code(
284
300
participant_id = self ._dss .participant_id ,
285
301
)
286
302
287
- self ._handle_query_result (
303
+ self .handle_query_result (
288
304
check = check ,
289
305
q = mutated_isa .dss_query ,
290
306
fail_msg = "ISA Put succeeded when expecting a failure" ,
@@ -327,7 +343,7 @@ def put_isa(
327
343
utm_client = self ._dss .client ,
328
344
participant_id = self ._dss .participant_id ,
329
345
)
330
- self ._handle_query_result (
346
+ self .handle_query_result (
331
347
main_check , mutated_isa .dss_query , f"Failed to insert ISA { isa_id } "
332
348
)
333
349
for notification_query in mutated_isa .notifications .values ():
@@ -458,7 +474,7 @@ def del_isa(
458
474
utm_client = self ._dss .client ,
459
475
participant_id = self ._dss .participant_id ,
460
476
)
461
- self ._handle_query_result (
477
+ self .handle_query_result (
462
478
main_check , del_isa .dss_query , f"Failed to delete ISA { isa_id } "
463
479
)
464
480
for notification_query in del_isa .notifications .values ():
@@ -544,7 +560,7 @@ def del_isa_expect_response_code(
544
560
participant_id = self ._dss .participant_id ,
545
561
)
546
562
547
- self ._handle_query_result (
563
+ self .handle_query_result (
548
564
check = main_check ,
549
565
q = del_isa .dss_query ,
550
566
required_status_code = expected_error_codes ,
@@ -572,7 +588,7 @@ def cleanup_isa(
572
588
participant_id = self ._dss .participant_id ,
573
589
)
574
590
575
- self ._handle_query_result (
591
+ self .handle_query_result (
576
592
check , isa , f"Failed to get ISA { isa_id } " , {404 , 200 }, Severity .Medium
577
593
)
578
594
@@ -587,7 +603,7 @@ def cleanup_isa(
587
603
participant_id = self ._dss .participant_id ,
588
604
)
589
605
590
- self ._handle_query_result (
606
+ self .handle_query_result (
591
607
check ,
592
608
del_isa .dss_query ,
593
609
f"Failed to delete ISA { isa_id } " ,
@@ -621,7 +637,7 @@ def search_subs_expect_response_code(
621
637
participant_id = self ._dss .participant_id ,
622
638
)
623
639
624
- self ._handle_query_result (
640
+ self .handle_query_result (
625
641
check = check ,
626
642
q = subs ,
627
643
fail_msg = f"Search for subscriptions in area { area } failed to yield a result code in { expected_codes } " ,
@@ -654,7 +670,7 @@ def search_subs(
654
670
participant_id = self ._dss .participant_id ,
655
671
)
656
672
657
- self ._handle_query_result (
673
+ self .handle_query_result (
658
674
check , subs , f"Failed to search subscriptions in { area } "
659
675
)
660
676
return subs
@@ -683,7 +699,7 @@ def get_sub_expect_response_code(
683
699
participant_id = self ._dss .participant_id ,
684
700
)
685
701
686
- self ._handle_query_result (
702
+ self .handle_query_result (
687
703
check = check ,
688
704
q = sub ,
689
705
fail_msg = f"The request to get subscription with ID { sub_id } yielded a response code that wasn't in { expected_response_codes } " ,
@@ -718,9 +734,7 @@ def get_sub(
718
734
participant_id = self ._dss .participant_id ,
719
735
)
720
736
721
- self ._handle_query_result (
722
- check , sub , f"Failed to get subscription { sub_id } "
723
- )
737
+ self .handle_query_result (check , sub , f"Failed to get subscription { sub_id } " )
724
738
725
739
if sub_id != sub .subscription .id :
726
740
check .record_failed (
@@ -758,7 +772,7 @@ def no_sub(
758
772
participant_id = self ._dss .participant_id ,
759
773
)
760
774
761
- self ._handle_query_result (
775
+ self .handle_query_result (
762
776
check , sub , f"Failed to get subscription { sub_id } " , {404 }
763
777
)
764
778
return
@@ -801,7 +815,7 @@ def put_sub_expect_response_code(
801
815
participant_id = self ._dss .participant_id ,
802
816
)
803
817
804
- self ._handle_query_result (
818
+ self .handle_query_result (
805
819
check = check ,
806
820
q = created_sub ,
807
821
required_status_code = expected_error_codes ,
@@ -850,7 +864,7 @@ def put_sub(
850
864
participant_id = self ._dss .participant_id ,
851
865
)
852
866
853
- self ._handle_query_result (
867
+ self .handle_query_result (
854
868
check , created_sub , f"Failed to insert subscription { sub_id } "
855
869
)
856
870
return created_sub
@@ -883,7 +897,7 @@ def del_sub_expect_response_code(
883
897
participant_id = self ._dss .participant_id ,
884
898
)
885
899
886
- self ._handle_query_result (
900
+ self .handle_query_result (
887
901
check = check ,
888
902
q = del_sub ,
889
903
fail_msg = f"Query to delete subscription with ID { sub_id } wit not yield a response code in { expected_response_codes } " ,
@@ -918,7 +932,7 @@ def del_sub(
918
932
participant_id = self ._dss .participant_id ,
919
933
)
920
934
921
- self ._handle_query_result (
935
+ self .handle_query_result (
922
936
check , del_sub , f"Failed to delete subscription { sub_id } "
923
937
)
924
938
@@ -963,7 +977,7 @@ def cleanup_subs_in_area(
963
977
participant_id = self ._dss .participant_id ,
964
978
)
965
979
966
- self ._handle_query_result (
980
+ self .handle_query_result (
967
981
check ,
968
982
del_sub ,
969
983
f"Failed to delete subscription { sub } " ,
@@ -996,7 +1010,7 @@ def cleanup_sub(
996
1010
participant_id = self ._dss .participant_id ,
997
1011
)
998
1012
999
- self ._handle_query_result (
1013
+ self .handle_query_result (
1000
1014
check ,
1001
1015
sub ,
1002
1016
f"Failed to get subscription { sub_id } " ,
@@ -1018,7 +1032,7 @@ def cleanup_sub(
1018
1032
participant_id = self ._dss .participant_id ,
1019
1033
)
1020
1034
1021
- self ._handle_query_result (
1035
+ self .handle_query_result (
1022
1036
check ,
1023
1037
del_sub ,
1024
1038
f"Failed to delete subscription { sub_id } " ,
@@ -1075,7 +1089,7 @@ def raw_request_with_expected_code(
1075
1089
else :
1076
1090
raise ValueError (f"Unknown RID version: { self ._dss .rid_version } " )
1077
1091
1078
- self ._handle_query_result (
1092
+ self .handle_query_result (
1079
1093
check ,
1080
1094
rid_query ,
1081
1095
fail_msg ,
0 commit comments