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

10 statements  

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

1from decimal import Decimal 

2 

3from prisma import Prisma 

4 

5 

6def test_pushing_decimal(client: Prisma) -> None: 

7 """Pushing a Decimal[] value""" 

8 models = [ 

9 client.lists.create({}), 

10 client.lists.create( 

11 data={ 

12 'decimals': [Decimal('22.99'), Decimal('30.01')], 

13 }, 

14 ), 

15 ] 

16 

17 model = client.lists.update( 

18 where={ 

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

20 }, 

21 data={ 

22 'decimals': { 

23 'push': [Decimal('22.99'), Decimal('31')], 

24 }, 

25 }, 

26 ) 

27 assert model is not None 

28 assert model.decimals == [Decimal('22.99'), Decimal('31')] 

29 

30 model = client.lists.update( 

31 where={ 

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

33 }, 

34 data={ 

35 'decimals': { 

36 'push': [Decimal('5')], 

37 }, 

38 }, 

39 ) 

40 assert model is not None 

41 assert model.decimals == [Decimal('22.99'), Decimal('30.01'), Decimal('5')]