Coverage for databases/tests/arrays/push/test_decimal.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
1from decimal import Decimal
3import pytest
5from prisma import Prisma
8@pytest.mark.asyncio
9async def test_pushing_decimal(client: Prisma) -> None:
10 """Pushing a Decimal[] value"""
11 models = [
12 await client.lists.create({}),
13 await client.lists.create(
14 data={
15 'decimals': [Decimal('22.99'), Decimal('30.01')],
16 },
17 ),
18 ]
20 model = await client.lists.update(
21 where={
22 'id': models[0].id,
23 },
24 data={
25 'decimals': {
26 'push': [Decimal('22.99'), Decimal('31')],
27 },
28 },
29 )
30 assert model is not None
31 assert model.decimals == [Decimal('22.99'), Decimal('31')]
33 model = await client.lists.update(
34 where={
35 'id': models[1].id,
36 },
37 data={
38 'decimals': {
39 'push': [Decimal('5')],
40 },
41 },
42 )
43 assert model is not None
44 assert model.decimals == [Decimal('22.99'), Decimal('30.01'), Decimal('5')]