Coverage for databases/tests/arrays/push/test_enum.py: 100%
12 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1import pytest
3from prisma import Prisma
4from prisma.enums import Role
7@pytest.mark.asyncio
8async def test_pushing_enum(client: Prisma) -> None:
9 """Pushing a Role[] enum value"""
10 models = [
11 await client.lists.create({}),
12 await client.lists.create(
13 data={
14 'roles': [Role.USER, Role.ADMIN],
15 },
16 ),
17 ]
19 model = await client.lists.update(
20 where={
21 'id': models[0].id,
22 },
23 data={
24 'roles': {
25 'push': [Role.ADMIN, Role.USER],
26 },
27 },
28 )
29 assert model is not None
30 assert model.roles == [Role.ADMIN, Role.USER]
32 model = await client.lists.update(
33 where={
34 'id': models[1].id,
35 },
36 data={
37 'roles': {
38 'push': [Role.EDITOR],
39 },
40 },
41 )
42 assert model is not None
43 assert model.roles == [Role.USER, Role.ADMIN, Role.EDITOR]