@@ -33,59 +33,59 @@ def client_search_testing(
3333 custom_field_tests (dict[str, Any]): Custom queries for specific fields.
3434 sub_doc_fields (list[str]): Prefixes for fields to check in resulting data. Useful when data to be tested is nested.
3535 """
36- if search_method is not None :
37- # Get list of parameters
38- param_tuples = list (search_method .__annotations__ .items ())
36+ if search_method is None :
37+ return
38+ # Get list of parameters
39+ param_tuples = list (search_method .__annotations__ .items ())
3940
40- # Query API for each numeric and boolean parameter and check if returned
41- for entry in param_tuples :
42- param = entry [0 ]
41+ # Query API for each numeric and boolean parameter and check if returned
42+ for entry in param_tuples :
43+ param = entry [0 ]
4344
44- if param not in excluded_params + ["return" ]:
45- param_type = entry [1 ]
46- q = None
45+ if param not in excluded_params + ["return" ]:
46+ param_type = entry [1 ]
47+ q = None
4748
48- if "tuple[int, int]" in param_type :
49- project_field = alt_name_dict .get (param , None )
50- q = {
51- param : (- 100 , 100 ),
52- "chunk_size" : 1 ,
53- "num_chunks" : 1 ,
54- }
55- elif "tuple[float, float]" in param_type :
56- project_field = alt_name_dict .get (param , None )
57- q = {
58- param : (- 100.12 , 100.12 ),
59- "chunk_size" : 1 ,
60- "num_chunks" : 1 ,
61- }
62- elif "bool" in param_type :
63- project_field = alt_name_dict .get (param , None )
64- q = {
65- param : False ,
66- "chunk_size" : 1 ,
67- "num_chunks" : 1 ,
68- }
69- elif param in custom_field_tests :
70- project_field = alt_name_dict .get (param , None )
71- q = {
72- param : custom_field_tests [param ],
73- "chunk_size" : 1 ,
74- "num_chunks" : 1 ,
75- }
49+ if "tuple[int, int]" in param_type :
50+ project_field = alt_name_dict .get (param , None )
51+ q = {
52+ param : (- 100 , 100 ),
53+ "chunk_size" : 1 ,
54+ "num_chunks" : 1 ,
55+ }
56+ elif "tuple[float, float]" in param_type :
57+ project_field = alt_name_dict .get (param , None )
58+ q = {
59+ param : (- 100.12 , 100.12 ),
60+ "chunk_size" : 1 ,
61+ "num_chunks" : 1 ,
62+ }
63+ elif "bool" in param_type :
64+ project_field = alt_name_dict .get (param , None )
65+ q = {
66+ param : False ,
67+ "chunk_size" : 1 ,
68+ "num_chunks" : 1 ,
69+ }
70+ elif param in custom_field_tests :
71+ project_field = alt_name_dict .get (param , None )
72+ q = {
73+ param : custom_field_tests [param ],
74+ "chunk_size" : 1 ,
75+ "num_chunks" : 1 ,
76+ }
7677
77- if q is None :
78- raise ValueError (
79- f"Parameter '{ param } ' with type '{ param_type } ' was not "
80- "properly identified in the generic search method test."
81- )
82- doc = search_method (** q )[0 ].model_dump ()
78+ if q is None :
79+ raise ValueError (
80+ f"Parameter '{ param } ' with type '{ param_type } ' was not "
81+ "properly identified in the generic search method test."
82+ )
83+ doc = search_method (** q )[0 ].model_dump ()
8384
84- for sub_field in sub_doc_fields :
85- if sub_field in doc :
86- doc = doc [sub_field ]
85+ for sub_field in sub_doc_fields :
86+ if sub_field in doc :
87+ doc = doc [sub_field ]
8788
88- assert (
89- doc [project_field if project_field is not None else param ]
90- is not None
91- )
89+ assert (
90+ doc [project_field if project_field is not None else param ] is not None
91+ )
0 commit comments