diff --git a/tests/test_date.py b/tests/test_date.py index 7ea636663..b560b38d9 100644 --- a/tests/test_date.py +++ b/tests/test_date.py @@ -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'),