Skip to content

Commit 4ea9261

Browse files
committed
➕ Add more tests to inherited manager model
1 parent 90d913c commit 4ea9261

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/managers/test_managers_inherited.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,22 @@ async def test_inherited_base_model_managers_product():
8989
await Product.query.create(name="test5", rating=2)
9090
await Product.query.create(name="test6", rating=1)
9191

92-
users = await Product.query.all()
93-
assert len(users) == 6
92+
products = await Product.query.all()
93+
assert len(products) == 6
9494

95-
users = await Product.ratings.all()
96-
assert len(users) == 3
95+
products = await Product.ratings.all()
96+
assert len(products) == 3
97+
98+
99+
async def test_raises_key_error_on_non_existing_field_for_product():
100+
await Product.query.create(name="test", rating=5)
101+
102+
with pytest.raises(KeyError):
103+
await Product.languages.all()
104+
105+
106+
async def test_raises_key_error_on_non_existing_field_for_user():
107+
await User.query.create(name="test", language="EN")
108+
109+
with pytest.raises(KeyError):
110+
await User.ratings.all()

0 commit comments

Comments
 (0)