Coverage for databases/sync_tests/arrays/push/test_enum.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-08-27 18:25 +0000

1from prisma import Prisma 

2from prisma.enums import Role 

3 

4 

5def test_pushing_enum(client: Prisma) -> None: 

6 """Pushing a Role[] enum value""" 

7 models = [ 

8 client.lists.create({}), 

9 client.lists.create( 

10 data={ 

11 'roles': [Role.USER, Role.ADMIN], 

12 }, 

13 ), 

14 ] 

15 

16 model = client.lists.update( 

17 where={ 

18 'id': models[0].id, 

19 }, 

20 data={ 

21 'roles': { 

22 'push': [Role.ADMIN, Role.USER], 

23 }, 

24 }, 

25 ) 

26 assert model is not None 

27 assert model.roles == [Role.ADMIN, Role.USER] 

28 

29 model = client.lists.update( 

30 where={ 

31 'id': models[1].id, 

32 }, 

33 data={ 

34 'roles': { 

35 'push': [Role.EDITOR], 

36 }, 

37 }, 

38 ) 

39 assert model is not None 

40 assert model.roles == [Role.USER, Role.ADMIN, Role.EDITOR]