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

Function test_create

tests/contrib/mysql/fields.py:16–33  ·  view source on GitHub ↗
(db)

Source from the content-addressed store, hash-verified

14
15@pytest.mark.asyncio
16async def test_create(db):
17 data = uuid.uuid4()
18 obj0 = await testmodels_mysql.UUIDFields.create(data=data)
19 assert isinstance(obj0.data, bytes)
20 assert isinstance(obj0.data_auto, bytes)
21 assert obj0.data_null is None
22 obj = await testmodels_mysql.UUIDFields.get(id=obj0.id)
23 assert isinstance(obj.data, uuid.UUID)
24 assert isinstance(obj.data_auto, uuid.UUID)
25 assert obj.data == data
26 assert obj.data_null is None
27 await obj.save()
28 obj2 = await testmodels_mysql.UUIDFields.get(id=obj.id)
29 assert obj == obj2
30
31 await obj.delete()
32 obj = await testmodels_mysql.UUIDFields.filter(id=obj0.id).first()
33 assert obj is None
34
35
36@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 6

saveMethod · 0.80
createMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45
firstMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…