Skip to content

Commit 471c388

Browse files
author
Carlos Carbo de Rico
authored
feat: add timestamp to be used as param [TIMESTAMP] (#231)
* feat: add timestamp to be used as param [TIMESTAMP] * typo in def * feat: add info in Changelog file
1 parent 336356b commit 471c388

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ v2.0.0
1111
- Move *get_valid_filename* and *makedirs_safe* methods from *toolium.path_utils* to *toolium.utils.path_utils*
1212
- Move *Utils* class from *toolium.utils* to *toolium.utils.driver_utils*
1313
- Fix report when an error happens in the Dynamic Environment
14+
- New param [TIMESTAMP] to generate timestamp value of the actual moment
1415

1516
v1.9.2
1617
------

toolium/test/utils/test_dataset_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ def test_replace_param_dict():
129129
assert param == {'a': 'test1', 'b': 'test2', 'c': 'test3'}
130130

131131

132+
def test_replace_param_timestamp():
133+
param = replace_param('[TIMESTAMP]')
134+
assert len(param) == 10
135+
assert datetime.datetime.strptime(str(datetime.datetime.fromtimestamp(int(param))), '%Y-%m-%d %H:%M:%S')
136+
137+
132138
def test_replace_param_datetime():
133139
param = replace_param('[DATETIME]')
134140
assert datetime.datetime.strptime(param, '%Y-%m-%d %H:%M:%S.%f')

toolium/utils/dataset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def replace_param(param, language='es'):
3636
[EMPTY] Empty string
3737
[B] Add Blank space
3838
[RANDOM] Generate random value
39-
[DATETIME] Add a timestamp
39+
[TIMESTAMP] Add a timestamp
40+
[DATETIME] Add a Datetime now
4041
[NOW] Similar to DATETIME without milliseconds
4142
[NOW + 2 DAYS] Similar to NOW but two days later
4243
[NOW - 1 MINUTES] Similar to NOW but one minute earlier
@@ -101,6 +102,7 @@ def _replace_param_replacement(param, language):
101102
'[EMPTY]': '',
102103
'[B]': ' ',
103104
'[RANDOM]': uuid.uuid4().hex[0:8],
105+
'[TIMESTAMP]': str(int(datetime.datetime.timestamp(datetime.datetime.utcnow()))),
104106
'[DATETIME]': str(datetime.datetime.utcnow()),
105107
'[NOW]': str(datetime.datetime.utcnow().strftime(date_format)),
106108
'[TODAY]': str(datetime.datetime.utcnow().strftime(date_day_format))

0 commit comments

Comments
 (0)