How to use _replace_param_date method in toolium

Best Python code snippet using toolium_python

dataset.py

Source:dataset.py Github

copy

Full Screen

...168 169 # append date expressions found in param to the replacement dict 170 date_expressions = _find_param_date_expressions(param)171 for date_expr in date_expressions:172 replacements[date_expr] = _replace_param_date(date_expr, language)[0]173 new_param = param174 param_replaced = False175 for key in replacements.keys():176 if key in new_param:177 new_param = new_param.replace(key, replacements[key])178 param_replaced = True179 return new_param, param_replaced180def _replace_param_transform_string(param):181 """182 Transform param value according to the specified prefix.183 Available transformations: DICT, LIST, INT, FLOAT, STR, UPPER, LOWER184 :param param: parameter value185 :return: tuple with replaced value and boolean to know if replacement has been done186 """187 type_mapping_regex = r'\[(DICT|LIST|INT|FLOAT|STR|UPPER|LOWER):(.*)\]'188 type_mapping_match_group = re.match(type_mapping_regex, param)189 new_param = param190 param_transformed = False191 if type_mapping_match_group:192 param_transformed = True193 if type_mapping_match_group.group(1) == 'STR':194 new_param = type_mapping_match_group.group(2)195 elif type_mapping_match_group.group(1) in ['LIST', 'DICT', 'INT', 'FLOAT']:196 exec('exec_param = {type}({value})'.format(type=type_mapping_match_group.group(1).lower(),197 value=type_mapping_match_group.group(2)))198 new_param = locals()['exec_param']199 elif type_mapping_match_group.group(1) == 'UPPER':200 new_param = type_mapping_match_group.group(2).upper()201 elif type_mapping_match_group.group(1) == 'LOWER':202 new_param = type_mapping_match_group.group(2).lower()203 return new_param, param_transformed204def _replace_param_date(param, language):205 """206 Transform param value in a date after applying the specified delta.207 E.g. [TODAY - 2 DAYS], [NOW - 10 MINUTES]208 An specific format could be defined in the case of NOW this way: NOW('THEFORMAT')209 where THEFORMAT is any valid format accepted by the python 210 [datetime.strftime](https://docs.python.org/3/library/datetime.html#datetime.date.strftime) function 211 :param param: parameter value212 :param language: language to configure date format for NOW and TODAY213 :return: tuple with replaced value and boolean to know if replacement has been done214 """215 def _date_matcher():216 return re.match(r'\[(NOW(?:\((?:.*)\)|)|TODAY)(?:\s*([\+|-]\s*\d+)\s*(\w+)\s*)?\]', param)217 def _offset_datetime(amount, units):218 now = datetime.datetime.utcnow()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful