MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / test_error

Function test_error

tests/fields/test_json.py:55–72  ·  view source on GitHub ↗

Test that invalid JSON raises FieldError.

(db)

Source from the content-addressed store, hash-verified

53
54@pytest.mark.asyncio
55async def test_error(db):
56 """Test that invalid JSON raises FieldError."""
57 with pytest.raises(FieldError):
58 await testmodels.JSONFields.create(data='{"some": ')
59
60 obj = await testmodels.JSONFields.create(data='{"some": ["text", 3]}')
61 with pytest.raises(FieldError):
62 await testmodels.JSONFields.filter(pk=obj.pk).update(data='{"some": ')
63
64 with pytest.raises(FieldError):
65 obj.data = "error json"
66 await obj.save()
67
68 with pytest.raises(TypeError):
69 await testmodels.JSONFields.create(data=Decimal(0))
70
71 with pytest.raises(TypeError):
72 await testmodels.JSONFields.create(data_decimal=Index(fields=["data"]))
73
74
75@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 5

IndexClass · 0.90
updateMethod · 0.80
saveMethod · 0.80
createMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…