MCPcopy
hub / github.com/django/django / test_uuid7_shift_duration_field

Method test_uuid7_shift_duration_field

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

Source from the content-addressed store, hash-verified

45
46 @skipUnlessDBFeature("supports_uuid7_function_shift")
47 def test_uuid7_shift_duration_field(self):
48 shift = timedelta(minutes=1)
49 m = UUIDModel.objects.create(shift=shift)
50 now = datetime.now(timezone.utc)
51 UUIDModel.objects.update(uuid=UUID7("shift"))
52 m.refresh_from_db()
53 ts = int.from_bytes(m.uuid.bytes[:6])
54 uuid_timestamp = datetime.fromtimestamp(ts / 1000, tz=timezone.utc)
55 self.assertAlmostEqual(
56 (uuid_timestamp - now).total_seconds(), shift.total_seconds(), places=1
57 )
58
59 @skipIfDBFeature("supports_uuid4_function")
60 def test_uuid4_unsupported(self):

Callers

nothing calls this directly

Calls 5

UUID7Class · 0.90
createMethod · 0.45
nowMethod · 0.45
updateMethod · 0.45
refresh_from_dbMethod · 0.45

Tested by

no test coverage detected