12345678910111213141516171819 |
- import datetime
- import pytest
- import pytz
- from symuid._datetime import datetime_utc_now, unix_epoch_time_to_datetime_utc
- def test_datetime_utc_now():
- pytz_dt = datetime.datetime.now(pytz.timezone('UTC'))
- assert abs((datetime_utc_now() - pytz_dt).total_seconds()) < 5
- @pytest.mark.parametrize(('ts_sec', 'expected_dt'), [
- (1528795204,
- datetime.datetime(2018, 6, 12, 9, 20, 4, tzinfo=datetime.timezone.utc)),
- ])
- def test_unix_epoch_time_to_datetime_utc(ts_sec, expected_dt):
- assert expected_dt == unix_epoch_time_to_datetime_utc(ts_sec)
|