Skip to content

Commit

Permalink
test(test_date.py): add tests for negative timestamp evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
gutsytechster committed Jun 11, 2022
1 parent 76ad403 commit 22ff8ed
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_date.py
Expand Up @@ -726,6 +726,34 @@ def test_timestamp_in_microseconds(self):
datetime.fromtimestamp(1570308760).replace(microsecond=263111)
)

@parameterized.expand([
param(
input_timestamp='-1570308760',
negative_allowed=True,
result=datetime.fromtimestamp(-1570308760)
),
param(
input_timestamp='-1570308760',
negative_allowed=False,
result=None
),
param(
input_timestamp='1570308760',
negative_allowed=True,
result=None
),
param(
input_timestamp='1570308760',
negative_allowed=False,
result=datetime.fromtimestamp(1570308760)
)
])
def test_timestamp_with_negative(self, input_timestamp, negative_allowed, result):
self.assertEqual(
date.get_date_from_timestamp(input_timestamp, None, negative=negative_allowed),
result
)

@parameterized.expand([
param(date_string='15703087602631'),
param(date_string='157030876026xx'),
Expand Down

0 comments on commit 22ff8ed

Please sign in to comment.