MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_tz_clamping_utc

Method test_tz_clamping_utc

test/test_bson.py:1557–1571  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1555 )
1556
1557 def test_tz_clamping_utc(self):
1558 # Aware clamping default utc.
1559 opts = CodecOptions(datetime_conversion=DatetimeConversion.DATETIME_CLAMP, tz_aware=True)
1560 below = encode({"x": DatetimeMS(_datetime_to_millis(datetime.datetime.min) - 24 * 60 * 60)})
1561 dec_below = decode(below, opts)
1562 self.assertEqual(
1563 dec_below["x"], datetime.datetime.min.replace(tzinfo=datetime.timezone.utc)
1564 )
1565
1566 above = encode({"x": DatetimeMS(_datetime_to_millis(datetime.datetime.max) + 24 * 60 * 60)})
1567 dec_above = decode(above, opts)
1568 self.assertEqual(
1569 dec_above["x"],
1570 datetime.datetime.max.replace(tzinfo=datetime.timezone.utc, microsecond=999000),
1571 )
1572
1573 def test_tz_clamping_non_utc(self):
1574 for tz in [FixedOffset(60, "+1H"), FixedOffset(-60, "-1H")]:

Callers

nothing calls this directly

Calls 5

CodecOptionsClass · 0.90
encodeFunction · 0.90
DatetimeMSClass · 0.90
_datetime_to_millisFunction · 0.90
decodeFunction · 0.90

Tested by

no test coverage detected