@@ -125,8 +125,8 @@ def path_exists(document, path):
125
125
_prop , _resolved_path , _parent = traverse (document , path )
126
126
except LookupError :
127
127
return False
128
- else :
129
- return True
128
+
129
+ return True
130
130
131
131
132
132
def prune_properties_from_model (model , paths ):
@@ -282,18 +282,16 @@ def has_only_writable_identifiers(self):
282
282
)
283
283
284
284
def assert_write_only_property_does_not_exist (self , resource_model ):
285
-
286
285
error_list = []
287
286
if self .write_only_paths :
288
287
for write_only_property in self .write_only_paths :
289
288
val = self .key_error_safe_traverse (resource_model , write_only_property )
290
289
if val :
291
290
error_list .append (write_only_property [1 ])
292
291
assertion_error_message = (
293
- "The model MUST NOT return properties defined as "
294
- "writeOnlyProperties in the resource schema "
295
- "\n Write only properties in resource model : %s \n Output Resource Model : %s \n "
296
- % (error_list , resource_model )
292
+ "The model MUST NOT return properties defined as writeOnlyProperties"
293
+ " in the resource schema \n Write only properties in resource model :"
294
+ f" { error_list } \n Output Resource Model : { resource_model } \n "
297
295
)
298
296
assert not any (error_list ), assertion_error_message
299
297
@@ -302,13 +300,13 @@ def get_metadata(self):
302
300
properties = self ._schema ["properties" ]
303
301
except KeyError :
304
302
return set ()
305
- else :
306
- return {
307
- prop
308
- for prop in properties .keys ()
309
- if "insertionOrder" in properties [prop ]
310
- and properties [prop ]["insertionOrder" ] == "false"
311
- }
303
+
304
+ return {
305
+ prop
306
+ for prop in properties .keys ()
307
+ if "insertionOrder" in properties [prop ]
308
+ and properties [prop ]["insertionOrder" ] == "false"
309
+ }
312
310
313
311
@property
314
312
def strategy (self ):
@@ -456,11 +454,10 @@ def compare(self, inputs, outputs):
456
454
457
455
def compare_model (self , inputs , outputs , path = ()):
458
456
assertion_error_message = (
459
- "All properties specified in the request MUST "
460
- "be present in the model returned, and they MUST"
461
- " match exactly, with the exception of properties"
462
- " defined as writeOnlyProperties in the resource schema \n Request Model : %s \n Returned Model : %s \n "
463
- % (inputs , outputs )
457
+ "All properties specified in the request MUST be present in the model"
458
+ " returned, and they MUST match exactly, with the exception of properties"
459
+ " defined as writeOnlyProperties in the resource schema \n Request Model :"
460
+ f" { inputs } \n Returned Model : { outputs } \n "
464
461
)
465
462
try :
466
463
if isinstance (inputs , dict ):
@@ -488,13 +485,9 @@ def compare_model(self, inputs, outputs, path=()):
488
485
else :
489
486
if inputs [key ] != outputs [key ]:
490
487
assertion_error_message = (
491
- "%s Value for property %s in Request Model(%s) and Response Model(%s) does not match"
492
- % (
493
- assertion_error_message ,
494
- key ,
495
- inputs [key ],
496
- outputs [key ],
497
- )
488
+ f"{ assertion_error_message } Value for property { key } in"
489
+ f" Request Model({ inputs [key ]} ) and Response"
490
+ f" Model({ outputs [key ]} ) does not match"
498
491
)
499
492
assert inputs [key ] == outputs [key ], assertion_error_message
500
493
else :
@@ -612,9 +605,9 @@ def assert_time(self, start_time, end_time, action):
612
605
if action in (Action .READ , Action .LIST )
613
606
else self ._timeout_in_seconds * 2
614
607
)
615
- assert end_time - start_time <= timeout_in_seconds , (
616
- "Handler %r timed out." % action
617
- )
608
+ assert (
609
+ end_time - start_time <= timeout_in_seconds
610
+ ), f"Handler { action !r } timed out."
618
611
619
612
@staticmethod
620
613
def assert_primary_identifier (primary_identifier_paths , resource_model ):
@@ -646,8 +639,8 @@ def is_primary_identifier_equal(
646
639
)
647
640
except KeyError as e :
648
641
raise AssertionError (
649
- "The primaryIdentifier returned in every progress event must\
650
- match the primaryIdentifier passed into the request"
642
+ "The primaryIdentifier returned in every progress event must "
643
+ " match the primaryIdentifier passed into the request"
651
644
) from e
652
645
653
646
@staticmethod
@@ -662,8 +655,8 @@ def get_primary_identifier(primary_identifier_path, model):
662
655
return pid_list
663
656
except KeyError as e :
664
657
raise AssertionError (
665
- "The primaryIdentifier returned in every progress event must\
666
- match the primaryIdentifier passed into the request \n "
658
+ "The primaryIdentifier returned in every progress event must "
659
+ " match the primaryIdentifier passed into the request \n "
667
660
) from e
668
661
669
662
def _make_payload (
@@ -761,7 +754,7 @@ def call_and_assert(
761
754
if not self .has_required_handlers ():
762
755
raise ValueError ("Create/Read/Delete handlers are required" )
763
756
if assert_status not in [OperationStatus .SUCCESS , OperationStatus .FAILED ]:
764
- raise ValueError ("Assert status {} not supported." . format ( assert_status ) )
757
+ raise ValueError (f "Assert status { assert_status } not supported." )
765
758
766
759
status , response = self .call (action , current_model , previous_model , ** kwargs )
767
760
if assert_status == OperationStatus .SUCCESS :
@@ -857,7 +850,7 @@ def validate_model_contain_tags(self, inputs):
857
850
if key == tag_property_name :
858
851
return True
859
852
else :
860
- raise assertion_error_message
853
+ raise AssertionError ( assertion_error_message )
861
854
except Exception as exception :
862
855
raise AssertionError (assertion_error_message ) from exception
863
856
return False
0 commit comments