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

Function test_manager

tests/test_manager.py:7–21  ·  view source on GitHub ↗

Test custom manager functionality with active status filtering.

(db)

Source from the content-addressed store, hash-verified

5
6@pytest.mark.asyncio
7async def test_manager(db):
8 """Test custom manager functionality with active status filtering."""
9 m1 = await ManagerModel.create()
10 m2 = await ManagerModel.create(status=1)
11
12 assert await ManagerModel.all().active().count() == 1
13 assert await ManagerModel.all_objects.count() == 2
14
15 assert await ManagerModel.all().active().get_or_none(pk=m1.pk) is None
16 assert await ManagerModel.all_objects.get_or_none(pk=m1.pk) is not None
17 assert await ManagerModel.get_or_none(pk=m2.pk) is not None
18
19 await ManagerModelExtra.create(extra="extra")
20 assert await ManagerModelExtra.all_objects.count() == 1
21 assert await ManagerModelExtra.all().count() == 1

Callers

nothing calls this directly

Calls 5

countMethod · 0.80
activeMethod · 0.80
createMethod · 0.45
allMethod · 0.45
get_or_noneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…