Test that adding unsaved model raises OperationalError.
(db)
| 122 | |
| 123 | @pytest.mark.asyncio |
| 124 | async def test__add_uninstantiated(db): |
| 125 | """Test that adding unsaved model raises OperationalError.""" |
| 126 | one = testmodels.M2MOne(name="One") |
| 127 | two = await testmodels.M2MTwo.create(name="Two") |
| 128 | with pytest.raises(OperationalError, match=r"You should first call .save\(\) on <M2MOne>"): |
| 129 | await two.one.add(one) |
| 130 | |
| 131 | |
| 132 | @pytest.mark.asyncio |