MCPcopy
hub / github.com/tortoise/tortoise-orm / test_datetime_update

Function test_datetime_update

tests/fields/test_time.py:99–111  ·  view source on GitHub ↗

Test updating datetime fields via filter().update() with use_tz=True.

(db, tz_env)

Source from the content-addressed store, hash-verified

97
98@pytest.mark.asyncio
99async def test_datetime_update(db, tz_env):
100 """Test updating datetime fields via filter().update() with use_tz=True."""
101 model = testmodels.DatetimeFields
102 os.environ["USE_TZ"] = "True"
103 timezone._reset_timezone_cache()
104
105 obj0 = await model.create(datetime=datetime(2019, 9, 1, 0, 0, 0, tzinfo=get_default_timezone()))
106 await model.filter(id=obj0.id).update(
107 datetime=datetime(2019, 9, 1, 6, 0, 8, tzinfo=get_default_timezone())
108 )
109 obj = await model.get(id=obj0.id)
110 assert obj.datetime == datetime(2019, 9, 1, 6, 0, 8, tzinfo=get_default_timezone())
111 assert obj.datetime_null is None
112
113
114@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 5

get_default_timezoneFunction · 0.90
updateMethod · 0.80
createMethod · 0.45
filterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…