MCPcopy
hub / github.com/django/django / test_uuid7_shift

Method test_uuid7_shift

tests/db_functions/test_uuid.py:36–44  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

34
35 @skipUnlessDBFeature("supports_uuid7_function_shift")
36 def test_uuid7_shift(self):
37 shift = timedelta(minutes=1)
38 now = datetime.now(timezone.utc)
39 m = UUIDModel.objects.create(uuid=UUID7(shift))
40 ts = int.from_bytes(m.uuid.bytes[:6])
41 uuid_timestamp = datetime.fromtimestamp(ts / 1000, tz=timezone.utc)
42 self.assertAlmostEqual(
43 (uuid_timestamp - now).total_seconds(), shift.total_seconds(), places=1
44 )
45
46 @skipUnlessDBFeature("supports_uuid7_function_shift")
47 def test_uuid7_shift_duration_field(self):

Callers

nothing calls this directly

Calls 3

UUID7Class · 0.90
nowMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected