def test_ulid_from_time(): ulid1 = ULID.from_timestamp(time.time()) ulid2 = ULID.from_datetime(utcnow()) now = utcnow() t = time.time() assert ulid1.timestamp == pytest.approx(t) datetimes_almost_equal(ulid1.datetime, now) assert ulid2.timestamp == pytest.approx(t) datetimes_almost_equal(ulid2.datetime, now)
def test_ulid_from_timestamp(): t = time.time() ulid1 = ULID.from_timestamp(t) ulid2 = ULID.from_timestamp(int(t * constants.MILLISECS_IN_SECS)) assert ulid1.timestamp == ulid2.timestamp