@@ -206,7 +206,8 @@ def __init__(self, test: dict, config: dict, definitions):
206
206
self .fabric_filtered = _value_or_none (test , 'fabricFiltered' )
207
207
self .min_interval = _value_or_none (test , 'minInterval' )
208
208
self .max_interval = _value_or_none (test , 'maxInterval' )
209
- self .timed_interaction_timeout_ms = _value_or_none (test , 'timedInteractionTimeoutMs' )
209
+ self .timed_interaction_timeout_ms = _value_or_none (
210
+ test , 'timedInteractionTimeoutMs' )
210
211
self .busy_wait_ms = _value_or_none (test , 'busyWaitMs' )
211
212
212
213
self .is_attribute = self .command in _ATTRIBUTE_COMMANDS
@@ -215,8 +216,10 @@ def __init__(self, test: dict, config: dict, definitions):
215
216
self .arguments_with_placeholders = _value_or_none (test , 'arguments' )
216
217
self .response_with_placeholders = _value_or_none (test , 'response' )
217
218
218
- _check_valid_keys (self .arguments_with_placeholders , _TEST_ARGUMENTS_SECTION )
219
- _check_valid_keys (self .response_with_placeholders , _TEST_RESPONSE_SECTION )
219
+ _check_valid_keys (self .arguments_with_placeholders ,
220
+ _TEST_ARGUMENTS_SECTION )
221
+ _check_valid_keys (self .response_with_placeholders ,
222
+ _TEST_RESPONSE_SECTION )
220
223
221
224
self ._convert_single_value_to_values (self .arguments_with_placeholders )
222
225
self ._convert_single_value_to_values (self .response_with_placeholders )
@@ -225,20 +228,26 @@ def __init__(self, test: dict, config: dict, definitions):
225
228
response_mapping = None
226
229
227
230
if self .is_attribute :
228
- attribute = definitions .get_attribute_by_name (self .cluster , self .attribute )
231
+ attribute = definitions .get_attribute_by_name (
232
+ self .cluster , self .attribute )
229
233
if attribute :
230
234
attribute_mapping = self ._as_mapping (definitions , self .cluster ,
231
235
attribute .definition .data_type .name )
232
236
argument_mapping = attribute_mapping
233
237
response_mapping = attribute_mapping
234
238
else :
235
- command = definitions .get_command_by_name (self .cluster , self .command )
239
+ command = definitions .get_command_by_name (
240
+ self .cluster , self .command )
236
241
if command :
237
- argument_mapping = self ._as_mapping (definitions , self .cluster , command .input_param )
238
- response_mapping = self ._as_mapping (definitions , self .cluster , command .output_param )
242
+ argument_mapping = self ._as_mapping (
243
+ definitions , self .cluster , command .input_param )
244
+ response_mapping = self ._as_mapping (
245
+ definitions , self .cluster , command .output_param )
239
246
240
- self ._update_with_definition (self .arguments_with_placeholders , argument_mapping )
241
- self ._update_with_definition (self .response_with_placeholders , response_mapping )
247
+ self ._update_with_definition (
248
+ self .arguments_with_placeholders , argument_mapping )
249
+ self ._update_with_definition (
250
+ self .response_with_placeholders , response_mapping )
242
251
243
252
# This performs a very basic sanity parse time check of constrains. This parsing happens
244
253
# again inside post processing response since at that time we will have required variables
@@ -281,7 +290,8 @@ def _as_mapping(self, definitions, cluster_name, target_name):
281
290
if hasattr (element , 'base_type' ):
282
291
target_name = element .base_type .lower ()
283
292
elif hasattr (element , 'fields' ):
284
- target_name = {f .name : self ._as_mapping (definitions , cluster_name , f .data_type .name ) for f in element .fields }
293
+ target_name = {f .name : self ._as_mapping (
294
+ definitions , cluster_name , f .data_type .name ) for f in element .fields }
285
295
elif target_name :
286
296
target_name = target_name .lower ()
287
297
@@ -296,7 +306,8 @@ def _update_with_definition(self, container: dict, mapping_type):
296
306
mapping = mapping_type if self .is_attribute else mapping_type [value ['name' ]]
297
307
298
308
if key == 'value' :
299
- value [key ] = self ._update_value_with_definition (item_value , mapping )
309
+ value [key ] = self ._update_value_with_definition (
310
+ item_value , mapping )
300
311
elif key == 'saveAs' and type (item_value ) is str and item_value not in self ._parsing_config_variable_storage :
301
312
self ._parsing_config_variable_storage [item_value ] = None
302
313
elif key == 'constraints' :
@@ -321,7 +332,8 @@ def _update_value_with_definition(self, value, mapping_type):
321
332
rv [key ] = value [key ] # int64u
322
333
else :
323
334
mapping = mapping_type [key ]
324
- rv [key ] = self ._update_value_with_definition (value [key ], mapping )
335
+ rv [key ] = self ._update_value_with_definition (
336
+ value [key ], mapping )
325
337
return rv
326
338
if type (value ) is list :
327
339
return [self ._update_value_with_definition (entry , mapping_type ) for entry in value ]
@@ -331,7 +343,8 @@ def _update_value_with_definition(self, value, mapping_type):
331
343
if value is not None and value not in self ._parsing_config_variable_storage :
332
344
if mapping_type == 'int64u' or mapping_type == 'int64s' or mapping_type == 'bitmap64' or mapping_type == 'epoch_us' :
333
345
value = fixes .try_apply_yaml_cpp_longlong_limitation_fix (value )
334
- value = fixes .try_apply_yaml_unrepresentable_integer_for_javascript_fixes (value )
346
+ value = fixes .try_apply_yaml_unrepresentable_integer_for_javascript_fixes (
347
+ value )
335
348
elif mapping_type == 'single' or mapping_type == 'double' :
336
349
value = fixes .try_apply_yaml_float_written_as_strings (value )
337
350
elif mapping_type == 'octet_string' or mapping_type == 'long_octet_string' :
@@ -464,7 +477,7 @@ def _response_error_validation(self, response, result):
464
477
error_success = 'The test expects the "{error}" error which occured successfully.'
465
478
error_success_no_error = 'The test expects no error and no error occurred.'
466
479
error_wrong_error = 'The test expects the "{error}" error but the "{value}" error occured.'
467
- error_unexpected_error = 'The test expects no error but the "{value }" error occured.'
480
+ error_unexpected_error = 'The test expects no error but the "{error }" error occured.'
468
481
error_unexpected_success = 'The test expects the "{error}" error but no error occured.'
469
482
470
483
expected_error = self .response .get ('error' ) if self .response else None
@@ -478,14 +491,17 @@ def _response_error_validation(self, response, result):
478
491
received_error = response .get ('error' )
479
492
480
493
if expected_error and received_error and expected_error == received_error :
481
- result .success (check_type , error_success .format (error = expected_error ))
494
+ result .success (check_type , error_success .format (
495
+ error = expected_error ))
482
496
elif expected_error and received_error :
483
497
result .error (check_type , error_wrong_error .format (
484
498
error = expected_error , value = received_error ))
485
499
elif expected_error and not received_error :
486
- result .error (check_type , error_unexpected_success .format (error = expected_error ))
500
+ result .error (check_type , error_unexpected_success .format (
501
+ error = expected_error ))
487
502
elif not expected_error and received_error :
488
- result .error (check_type , error_unexpected_error .format (error = received_error ))
503
+ result .error (check_type , error_unexpected_error .format (
504
+ error = received_error ))
489
505
elif not expected_error and not received_error :
490
506
result .success (check_type , error_success_no_error )
491
507
else :
@@ -503,12 +519,14 @@ def _response_cluster_error_validation(self, response, result):
503
519
504
520
if expected_error :
505
521
if received_error and expected_error == received_error :
506
- result .success (check_type , error_success .format (error = expected_error ))
522
+ result .success (check_type , error_success .format (
523
+ error = expected_error ))
507
524
elif received_error :
508
525
result .error (check_type , error_wrong_error .format (
509
526
error = expected_error , value = received_error ))
510
527
else :
511
- result .error (check_type , error_unexpected_success .format (error = expected_error ))
528
+ result .error (check_type , error_unexpected_success .format (
529
+ error = expected_error ))
512
530
else :
513
531
# Nothing is logged here to not be redundant with the generic error checking code.
514
532
pass
@@ -528,10 +546,12 @@ def _response_values_validation(self, response, result):
528
546
if not self .is_attribute :
529
547
expected_name = value .get ('name' )
530
548
if expected_name not in received_value :
531
- result .error (check_type , error_name_does_not_exist .format (name = expected_name ))
549
+ result .error (check_type , error_name_does_not_exist .format (
550
+ name = expected_name ))
532
551
continue
533
552
534
- received_value = received_value .get (expected_name ) if received_value else None
553
+ received_value = received_value .get (
554
+ expected_name ) if received_value else None
535
555
536
556
# TODO Supports Array/List. See an exemple of failure in TestArmFailSafe.yaml
537
557
expected_value = value .get ('value' )
@@ -557,10 +577,12 @@ def _response_constraints_validation(self, response, result):
557
577
if not self .is_attribute :
558
578
expected_name = value .get ('name' )
559
579
if expected_name not in received_value :
560
- result .error (check_type , error_name_does_not_exist .format (name = expected_name ))
580
+ result .error (check_type , error_name_does_not_exist .format (
581
+ name = expected_name ))
561
582
continue
562
583
563
- received_value = received_value .get (expected_name ) if received_value else None
584
+ received_value = received_value .get (
585
+ expected_name ) if received_value else None
564
586
565
587
constraints = get_constraints (value ['constraints' ])
566
588
if all ([constraint .is_met (received_value ) for constraint in constraints ]):
@@ -583,14 +605,17 @@ def _maybe_save_as(self, response, result):
583
605
if not self .is_attribute :
584
606
expected_name = value .get ('name' )
585
607
if expected_name not in received_value :
586
- result .error (check_type , error_name_does_not_exist .format (name = expected_name ))
608
+ result .error (check_type , error_name_does_not_exist .format (
609
+ name = expected_name ))
587
610
continue
588
611
589
- received_value = received_value .get (expected_name ) if received_value else None
612
+ received_value = received_value .get (
613
+ expected_name ) if received_value else None
590
614
591
615
save_as = value .get ('saveAs' )
592
616
self ._runtime_config_variable_storage [save_as ] = received_value
593
- result .success (check_type , error_success .format (value = received_value , name = save_as ))
617
+ result .success (check_type , error_success .format (
618
+ value = received_value , name = save_as ))
594
619
595
620
def _update_placeholder_values (self , container ):
596
621
if not container :
@@ -600,7 +625,8 @@ def _update_placeholder_values(self, container):
600
625
601
626
for idx , item in enumerate (values ):
602
627
if 'value' in item :
603
- values [idx ]['value' ] = self ._config_variable_substitution (item ['value' ])
628
+ values [idx ]['value' ] = self ._config_variable_substitution (
629
+ item ['value' ])
604
630
605
631
if 'constraints' in item :
606
632
for constraint , constraint_value in item ['constraints' ].items ():
@@ -615,7 +641,8 @@ def _config_variable_substitution(self, value):
615
641
elif type (value ) is dict :
616
642
mapped_value = {}
617
643
for key in value :
618
- mapped_value [key ] = self ._config_variable_substitution (value [key ])
644
+ mapped_value [key ] = self ._config_variable_substitution (
645
+ value [key ])
619
646
return mapped_value
620
647
elif type (value ) is str :
621
648
# For most tests, a single config variable is used and it can be replaced as in.
@@ -669,7 +696,8 @@ def __init__(self, parsing_config_variable_storage: dict, definitions, tests: di
669
696
fixes .try_update_yaml_node_id_test_runner_state (
670
697
enabled_tests , self ._parsing_config_variable_storage )
671
698
672
- self ._runtime_config_variable_storage = copy .deepcopy (parsing_config_variable_storage )
699
+ self ._runtime_config_variable_storage = copy .deepcopy (
700
+ parsing_config_variable_storage )
673
701
self ._tests = enabled_tests
674
702
self ._index = 0
675
703
self .count = len (self ._tests )
@@ -692,18 +720,21 @@ def __init__(self, test_file, pics_file, definitions):
692
720
# TODO Needs supports for PICS file
693
721
with open (test_file ) as f :
694
722
loader = yaml .FullLoader
695
- loader = fixes .try_add_yaml_support_for_scientific_notation_without_dot (loader )
723
+ loader = fixes .try_add_yaml_support_for_scientific_notation_without_dot (
724
+ loader )
696
725
697
726
data = yaml .load (f , Loader = loader )
698
727
_check_valid_keys (data , _TESTS_SECTION )
699
728
700
729
self .name = _value_or_none (data , 'name' )
701
730
self .PICS = _value_or_none (data , 'PICS' )
702
731
703
- self ._parsing_config_variable_storage = _value_or_none (data , 'config' )
732
+ self ._parsing_config_variable_storage = _value_or_none (
733
+ data , 'config' )
704
734
705
735
tests = _value_or_none (data , 'tests' )
706
- self .tests = YamlTests (self ._parsing_config_variable_storage , definitions , tests )
736
+ self .tests = YamlTests (
737
+ self ._parsing_config_variable_storage , definitions , tests )
707
738
708
739
def update_config (self , key , value ):
709
740
self ._parsing_config_variable_storage [key ] = value
0 commit comments