1616from copy import copy , deepcopy
1717from enum import IntEnum
1818from functools import cmp_to_key
19- from typing import Union
19+ from typing import Dict , List , Union
2020import random
2121import string
2222from ..Config import MS05_INVASIVE_TESTING
@@ -133,7 +133,7 @@ def reset_device_model(self):
133133 self .is14_utils .device_model = None
134134 self .oid_cache = []
135135
136- def _do_request_json (self , test : GenericTest , method : str , url : str , ** kwargs ):
136+ def _do_request_json (self , test : GenericTest , method : str , url : str , ** kwargs ) -> any :
137137 """Perform an HTTP request and return JSON response"""
138138 valid , response = self .do_request (method , url , ** kwargs )
139139
@@ -151,7 +151,7 @@ def _do_request_json(self, test: GenericTest, method: str, url: str, **kwargs):
151151
152152 return response .json ()
153153
154- def _compare_property_ids (self , a : NcPropertyId , b : NcPropertyId ):
154+ def _compare_property_ids (self , a : NcPropertyId , b : NcPropertyId ) -> int :
155155 """Compare level and index of an NcPropertyId"""
156156 if a .level > b .level :
157157 return 1
@@ -166,7 +166,7 @@ def _compare_property_ids(self, a: NcPropertyId, b: NcPropertyId):
166166
167167 def _compare_property_objects (self ,
168168 a : Union [NcPropertyDescriptor , NcPropertyHolder ],
169- b : Union [NcPropertyDescriptor , NcPropertyHolder ]):
169+ b : Union [NcPropertyDescriptor , NcPropertyHolder ]) -> int :
170170 """Compare NcPropertyIds of NcPropertyDescriptors or NcPropertyHolders"""
171171 return self ._compare_property_ids (a .id , b .id )
172172
@@ -187,7 +187,7 @@ def _to_dict(self, obj):
187187 else :
188188 return obj
189189
190- def _get_bulk_properties_holder (self , test : GenericTest , endpoint : str ):
190+ def _get_bulk_properties_holder (self , test : GenericTest , endpoint : str ) -> NcBulkPropertiesHolder :
191191 """Get backup dataset from endpoint"""
192192 method_result_json = self ._do_request_json (test , "GET" , endpoint )
193193
@@ -213,7 +213,7 @@ def _apply_bulk_properties_holder(self,
213213 endpoint : str ,
214214 bulk_properties_holder : NcBulkPropertiesHolder ,
215215 restoreMode : NcRestoreMode ,
216- recurse : bool ):
216+ recurse : bool ) -> List [ NcObjectPropertiesSetValidation ] :
217217 """Apply a backup dataset to the endpoint"""
218218 backup_dataset = {
219219 "arguments" : {
@@ -253,7 +253,7 @@ def _restore_bulk_properties_holder(self,
253253 endpoint : str ,
254254 bulk_properties_holder : NcBulkPropertiesHolder ,
255255 restoreMode = NcRestoreMode .Modify ,
256- recurse = True ):
256+ recurse = True ) -> List [ NcObjectPropertiesSetValidation ] :
257257 """Perform an HTTP PUT of the backup dataset to the endpoint"""
258258 return self ._apply_bulk_properties_holder (test ,
259259 test_metadata ,
@@ -265,7 +265,7 @@ def _validate_bulk_properties_holder(self,
265265 endpoint : str ,
266266 bulk_properties_holder : NcBulkPropertiesHolder ,
267267 restoreMode = NcRestoreMode .Modify ,
268- recurse = True ):
268+ recurse = True ) -> List [ NcObjectPropertiesSetValidation ] :
269269 """Perform an HTTP PATCH of the backup dataset to the endpoint"""
270270 return self ._apply_bulk_properties_holder (test ,
271271 test_metadata ,
@@ -297,7 +297,7 @@ def test_02(self, test):
297297 + "/docs/API_requests.html#url-and-usage" )
298298 return test .PASS ()
299299
300- def _check_block_member_role_syntax (self , test : GenericTest , role_path : list [str ]):
300+ def _check_block_member_role_syntax (self , test : GenericTest , role_path : List [str ]):
301301 """Check syntax of roles in this block"""
302302 method_result = self .is14_utils .get_property (test , NcBlockProperties .MEMBERS .value , role_path = role_path )
303303
@@ -725,11 +725,12 @@ def test_14(self, test):
725725
726726 return test .PASS ()
727727
728- def _create_notices_list (self , set_validations : list [NcObjectPropertiesSetValidation ]):
728+ def _create_notices_list (self , set_validations : List [NcObjectPropertiesSetValidation ]) -> List [ str ] :
729729 """Create list of validation notices"""
730730 return ["." .join (v .path ) + str (n .id ) for v in set_validations for n in v .notices ]
731731
732- def _create_object_properties_dict (self , bulk_properties_holder : NcBulkPropertiesHolder ):
732+ def _create_object_properties_dict (self , bulk_properties_holder : NcBulkPropertiesHolder ) \
733+ -> Dict [str , NcObjectPropertiesHolder ]:
733734 """Creates a dict keyed on formatted role path and property id"""
734735 return {"." .join (o .path ) + str (v .id ): v for o in bulk_properties_holder .values for v in o .values }
735736
@@ -738,8 +739,8 @@ def _compare_backup_datasets(self,
738739 original_bulk_properties_holder : NcBulkPropertiesHolder ,
739740 applied_bulk_properties_holder : NcBulkPropertiesHolder ,
740741 updated_bulk_properties_holder : NcBulkPropertiesHolder ,
741- target_role_path : list [str ],
742- set_validations : list [NcObjectPropertiesSetValidation ],
742+ target_role_path : List [str ],
743+ set_validations : List [NcObjectPropertiesSetValidation ],
743744 recurse : bool , validate = False ):
744745 """Compare the original backup dataset to the updated, given the applied dataset"""
745746 # original_bulk_properties_holder is the state before dataset applied
@@ -805,8 +806,8 @@ def _compare_values(expected, actual):
805806 def _check_object_properties_set_validations (self ,
806807 test_metadata : TestMetadata ,
807808 bulk_properties_holder : NcBulkPropertiesHolder ,
808- validations : list [NcObjectPropertiesSetValidation ],
809- target_role_path : list [str ],
809+ validations : List [NcObjectPropertiesSetValidation ],
810+ target_role_path : List [str ],
810811 recurse : bool ):
811812 """Check that the NcObjectPropertiesSetValidations have no errors"""
812813 # Check there is one validation per object changed
@@ -851,7 +852,7 @@ def _check_object_properties_set_validations(self,
851852
852853 def _check_validate_restore_properties (self ,
853854 test : GenericTest ,
854- target_role_path : list [str ],
855+ target_role_path : List [str ],
855856 restoreMode : NcRestoreMode ,
856857 recurse : bool ):
857858 """Perform a validate and restore on the target role path"""
@@ -1041,7 +1042,7 @@ def test_20(self, test):
10411042
10421043 # Invasive testing
10431044
1044- def _generate_property_value (self , test : GenericTest , type_name : str , value : any ):
1045+ def _generate_property_value (self , test : GenericTest , type_name : str , value : any ) -> any :
10451046 """Generate a new value based on the existing value"""
10461047
10471048 # If this is a null property then not sure how to manipulate it
@@ -1125,8 +1126,8 @@ def _check_device_model_structure(self,
11251126
11261127 def _filter_property_holders (self ,
11271128 bulk_properties_holder : NcBulkPropertiesHolder ,
1128- filter_list : list [str ],
1129- include = False ):
1129+ filter_list : List [str ],
1130+ include = False ) -> NcBulkPropertiesHolder :
11301131 """Either include or exclude the filter_list property keys from the bulk properties holder"""
11311132 # if include = True then properties with keys found in filter_list are kept (all others removed)
11321133 # if include = False then properties with keys found in filter_list are removed
@@ -1147,7 +1148,7 @@ def _filter_property_holders(self,
11471148 def _perform_restore (self ,
11481149 test : GenericTest ,
11491150 test_metadata : TestMetadata ,
1150- target_role_path : list [str ],
1151+ target_role_path : List [str ],
11511152 bulk_properties_holder : NcBulkPropertiesHolder ,
11521153 original_bulk_properties_holder : NcBulkPropertiesHolder ,
11531154 restoreMode : NcRestoreMode ,
0 commit comments