@@ -201,6 +201,8 @@ def __init__(self, test: dict, config: dict, definitions: SpecDefinitions, pics_
201
201
self .max_interval = _value_or_none (test , 'maxInterval' )
202
202
self .timed_interaction_timeout_ms = _value_or_none (
203
203
test , 'timedInteractionTimeoutMs' )
204
+ self .data_version = _value_or_none (
205
+ test , 'dataVersion' )
204
206
self .busy_wait_ms = _value_or_none (test , 'busyWaitMs' )
205
207
self .wait_for = _value_or_none (test , 'wait' )
206
208
self .event_number = _value_or_none (test , 'eventNumber' )
@@ -412,7 +414,8 @@ def _convert_single_value_to_values(self, container):
412
414
# members of the 'values' array which is what is used for other tests.
413
415
value = {}
414
416
415
- known_keys_to_copy = ['value' , 'constraints' , 'saveAs' ]
417
+ known_keys_to_copy = ['value' , 'constraints' ,
418
+ 'saveAs' , 'saveDataVersionAs' ]
416
419
known_keys_to_allow = ['error' , 'clusterError' ]
417
420
418
421
for key , item in list (container .items ()):
@@ -473,6 +476,8 @@ def _update_with_definition(self, container: dict, mapping_type):
473
476
item_value , mapping )
474
477
elif key == 'saveAs' and type (item_value ) is str and item_value not in self ._parsing_config_variable_storage :
475
478
self ._parsing_config_variable_storage [item_value ] = None
479
+ elif key == 'saveDataVersionAs' and type (item_value ) is str and item_value not in self ._parsing_config_variable_storage :
480
+ self ._parsing_config_variable_storage [item_value ] = None
476
481
elif key == 'constraints' :
477
482
for constraint , constraint_value in item_value .items ():
478
483
# Only apply update_value_with_definition to constraints that have a value that depends on
@@ -563,6 +568,8 @@ def __init__(self, test: _TestStepWithPlaceholders, step_index: int, runtime_con
563
568
if test .is_pics_enabled :
564
569
self ._update_placeholder_values (self .arguments )
565
570
self ._update_placeholder_values (self .responses )
571
+ self ._test .data_version = self ._config_variable_substitution (
572
+ self ._test .data_version )
566
573
self ._test .node_id = self ._config_variable_substitution (
567
574
self ._test .node_id )
568
575
self ._test .run_if = self ._config_variable_substitution (
@@ -654,6 +661,10 @@ def max_interval(self):
654
661
def timed_interaction_timeout_ms (self ):
655
662
return self ._test .timed_interaction_timeout_ms
656
663
664
+ @property
665
+ def data_version (self ):
666
+ return self ._test .data_version
667
+
657
668
@property
658
669
def busy_wait_ms (self ):
659
670
return self ._test .busy_wait_ms
@@ -702,7 +713,10 @@ def post_process_response(self, received_responses):
702
713
expected_response , received_response , result )
703
714
self ._response_constraints_validation (
704
715
expected_response , received_response , result )
705
- self ._maybe_save_as (expected_response , received_response , result )
716
+ self ._maybe_save_as ('saveAs' , 'value' ,
717
+ expected_response , received_response , result )
718
+ self ._maybe_save_as ('saveDataVersionAs' , 'dataVersion' ,
719
+ expected_response , received_response , result )
706
720
707
721
# An empty response array in a test step (responses: []) implies that the test step does expect a response
708
722
# but without any associated value.
@@ -936,17 +950,17 @@ def _response_constraints_validation(self, expected_response, received_response,
936
950
e .update_context (expected_response , self .step_index )
937
951
result .error (check_type , error_failure , e )
938
952
939
- def _maybe_save_as (self , expected_response , received_response , result ):
953
+ def _maybe_save_as (self , key : str , default_target : str , expected_response , received_response , result ):
940
954
check_type = PostProcessCheckType .SAVE_AS_VARIABLE
941
955
error_success = 'The test save the value "{value}" as {name}.'
942
956
error_name_does_not_exist = 'The test expects a value named "{name}" but it does not exists in the response."'
943
957
944
958
for value in expected_response ['values' ]:
945
- if 'saveAs' not in value :
959
+ if key not in value :
946
960
continue
947
961
948
- received_value = received_response .get ('value' )
949
- if not self .is_attribute and not self .is_event :
962
+ received_value = received_response .get (default_target )
963
+ if not self .is_attribute and not self .is_event and not ( self . command in ANY_COMMANDS_LIST ) :
950
964
expected_name = value .get ('name' )
951
965
if received_value is None or expected_name not in received_value :
952
966
result .error (check_type , error_name_does_not_exist .format (
@@ -956,7 +970,7 @@ def _maybe_save_as(self, expected_response, received_response, result):
956
970
received_value = received_value .get (
957
971
expected_name ) if received_value else None
958
972
959
- save_as = value .get ('saveAs' )
973
+ save_as = value .get (key )
960
974
self ._runtime_config_variable_storage [save_as ] = received_value
961
975
result .success (check_type , error_success .format (
962
976
value = received_value , name = save_as ))
0 commit comments