Test that invalid JSON raises FieldError.
(db)
| 53 | |
| 54 | @pytest.mark.asyncio |
| 55 | async 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 |