From 2f3875c0ee0510d36c9376eb97a3db9b47f069de Mon Sep 17 00:00:00 2001 From: Patricia Roman Sanchez Date: Tue, 8 Oct 2024 12:14:16 +0200 Subject: [PATCH] Fix linter issues --- toolium/test/utils/test_dataset_map_param_context.py | 3 ++- toolium/utils/dataset.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/toolium/test/utils/test_dataset_map_param_context.py b/toolium/test/utils/test_dataset_map_param_context.py index 5a001336..d13442eb 100644 --- a/toolium/test/utils/test_dataset_map_param_context.py +++ b/toolium/test/utils/test_dataset_map_param_context.py @@ -456,6 +456,7 @@ class Context(object): dataset.behave_context = context assert map_param("[CONTEXT:list.cmsScrollableActions.-1.id]") == 'ask-for-negative' + def test_a_context_param_list_incorrect_negative_index(): """ Verification of a list with a incorrect negative index (In bounds) as CONTEXT @@ -482,7 +483,7 @@ class Context(object): } dataset.behave_context = context assert map_param("[CONTEXT:list.cmsScrollableActions.-5.id]") - + def test_a_context_param_list_oob_index(): """ diff --git a/toolium/utils/dataset.py b/toolium/utils/dataset.py index 781eb687..3c4e4346 100644 --- a/toolium/utils/dataset.py +++ b/toolium/utils/dataset.py @@ -241,11 +241,8 @@ def _replace_param_transform_string(param): if type_mapping_match_group: param_transformed = True - if type_mapping_match_group.group(1) in ['DICT', 'LIST', 'INT', 'FLOAT', 'ROUND']: - if '::' in type_mapping_match_group.group() and 'ROUND' in type_mapping_match_group.group(): - params_to_replace = type_mapping_match_group.group(2).split('::') - new_param = f"{round(float(params_to_replace[0]), int(params_to_replace[1])):.{int(params_to_replace[1])}f}" - elif type_mapping_match_group.group(1) == 'DICT': + if type_mapping_match_group.group(1) in ['DICT', 'LIST', 'INT', 'FLOAT']: + if type_mapping_match_group.group(1) == 'DICT': try: new_param = json.loads(type_mapping_match_group.group(2).strip()) except json.decoder.JSONDecodeError: @@ -282,6 +279,9 @@ def _update_param_transform_string(type_mapping_match_group): elif type_mapping_match_group.group(1) == 'TITLE': replace_param = "".join(map(min, zip(type_mapping_match_group.group(2), type_mapping_match_group.group(2).title()))) + elif type_mapping_match_group.group(1) == 'ROUND': + replace_params = type_mapping_match_group.group(2).split('::') + replace_param = f"{round(float(replace_params[0]), int(replace_params[1])):.{int(replace_params[1])} f }" return replace_param