diff --git a/toolium/test/utils/test_dataset_map_param_context.py b/toolium/test/utils/test_dataset_map_param_context.py index c2fd6790..56fe259d 100644 --- a/toolium/test/utils/test_dataset_map_param_context.py +++ b/toolium/test/utils/test_dataset_map_param_context.py @@ -454,7 +454,8 @@ class Context(object): } dataset.behave_context = context assert map_param("[CONTEXT:list.cmsScrollableActions.-1.id]") == 'ask-for-negative' - + + def test_a_context_param_list_oob_index(): """ Verification of a list with an incorrect index (Out of bounds) as CONTEXT diff --git a/toolium/test/utils/test_dataset_replace_param.py b/toolium/test/utils/test_dataset_replace_param.py index 1a9dad29..04a3e742 100644 --- a/toolium/test/utils/test_dataset_replace_param.py +++ b/toolium/test/utils/test_dataset_replace_param.py @@ -439,29 +439,33 @@ def test_replace_param_partial_string_with_length(): param = replace_param('parameter [STRING_WITH_LENGTH_5] is string') assert param == 'parameter aaaaa is string' + def test_replace_param_json(): test_json = '{"key": "value", "key_1": true}' param = replace_param(f'[JSON:{test_json}]') assert param == {"key": "value", "key_1": True} -def test_replace_param_json(): - param = replace_param(f'[REPLACE:https://url.com::https::http]') + +def test_replace_param_replace(): + param = replace_param('[REPLACE:https://url.com::https::http]') assert param == "http://url.com" - param = replace_param(f'[REPLACE:https://url.com::https://]') + param = replace_param('[REPLACE:https://url.com::https://]') assert param == "url.com" - + + def test_replace_param_date(): - param = replace_param(f'[DATE:1994-06-13T07:00:00::%d %m %Y]') + param = replace_param('[DATE:1994-06-13T07:00:00::%d %m %Y]') assert param == "13 06 1994" - param = replace_param(f'[DATE:1994-06-13T07:00:00::%d %b %Y]') + param = replace_param('[DATE:1994-06-13T07:00:00::%d %b %Y]') assert param == "13 JUN 1994" - param = replace_param(f'[DATE:1994-06-13T07:00:00::%H:%M]') + param = replace_param('[DATE:1994-06-13T07:00:00::%H:%M]') assert param == "07:00" - + + def test_replace_param_title(): - param = replace_param(f'[TITLE:hola hola]') + param = replace_param('[TITLE:hola hola]') assert param == "Hola Hola" - param = replace_param(f'[TITLE:holahola]') + param = replace_param('[TITLE:holahola]') assert param == "Holahola" - param = replace_param(f'[TITLE:hOlA]') - assert param == "Hola" \ No newline at end of file + param = replace_param('[TITLE:hOlA]') + assert param == "Hola" diff --git a/toolium/utils/dataset.py b/toolium/utils/dataset.py index c87d8697..a0d8ce1a 100644 --- a/toolium/utils/dataset.py +++ b/toolium/utils/dataset.py @@ -230,7 +230,7 @@ def _get_random_phone_number(): def _format_date_spanish(date, date_expected_format, date_actual_format='%Y-%m-%dT%H:%M:%SZ', capitalize=True): - """_format_date_spanish + """_format_date_spanish Format date to spanish :param str date: actual date @@ -251,6 +251,7 @@ def _format_date_spanish(date, date_expected_format, date_actual_format='%Y-%m-% return formated_date + def _replace_param_transform_string(param): """ Transform param value according to the specified prefix. @@ -292,8 +293,9 @@ def _replace_param_transform_string(param): replace_param = params_to_replace[0].replace(param_to_replace, replace_param).replace(' ', ' ').replace(' ', ' ') elif type_mapping_match_group.group(1) == 'DATE': params_to_replace = type_mapping_match_group.group(2).split('::') - date_actual_format='%Y/%m/%d %H:%M:%S' - replace_param = _format_date_spanish(params_to_replace[0], params_to_replace[1], date_actual_format, capitalize=False) + date_actual_format = '%Y/%m/%d %H:%M:%S' + replace_param = _format_date_spanish(params_to_replace[0], params_to_replace[1], date_actual_format,\ + capitalize=False) 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()))) @@ -317,7 +319,7 @@ def _replace_param_date(param, language): def _date_matcher(): return re.match(r'\[(NOW(?:\((?:.*)\)|)|TODAY)(?:\s*([\+|-]\s*\d+)\s*(\w+)\s*)?\]', param) - def _offset_datetime(amount, units): + def _offset_datetime(amount, units): now = datetime.datetime.now(pytz.timezone('Europe/Madrid')) if not amount or not units: return now