Coverage for databases/tests/arrays/push/test_float.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-04-28 15:17 +0000

1import pytest 

2 

3from prisma import Prisma 

4 

5 

6@pytest.mark.asyncio 

7async def test_pushing_floats(client: Prisma) -> None: 

8 """Pushing a Float[] value""" 

9 models = [ 

10 await client.lists.create({}), 

11 await client.lists.create( 

12 data={ 

13 'floats': [3.4, 6.8, 12.4], 

14 }, 

15 ), 

16 ] 

17 

18 model = await client.lists.update( 

19 where={ 

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

21 }, 

22 data={ 

23 'floats': { 

24 'push': [102.3, 500.7], 

25 }, 

26 }, 

27 ) 

28 assert model is not None 

29 assert model.floats == [102.3, 500.7] 

30 

31 model = await client.lists.update( 

32 where={ 

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

34 }, 

35 data={ 

36 'floats': { 

37 'push': [20], 

38 }, 

39 }, 

40 ) 

41 assert model is not None 

42 assert model.floats == [3.4, 6.8, 12.4, 20]