| 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): |