Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
promans718 committed Oct 4, 2024
1 parent e9132d5 commit d689d5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
3 changes: 2 additions & 1 deletion toolium/test/utils/test_dataset_map_param_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 16 additions & 12 deletions toolium/test/utils/test_dataset_replace_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
param = replace_param('[TITLE:hOlA]')
assert param == "Hola"
10 changes: 6 additions & 4 deletions toolium/utils/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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())))
Expand All @@ -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
Expand Down

0 comments on commit d689d5d

Please sign in to comment.