Test clearing all related objects from M2M relation.
(db)
| 100 | |
| 101 | @pytest.mark.asyncio |
| 102 | async def test__clear(db): |
| 103 | """Test clearing all related objects from M2M relation.""" |
| 104 | one = await testmodels.M2MOne.create(name="One") |
| 105 | two1 = await testmodels.M2MTwo.create(name="Two") |
| 106 | two2 = await testmodels.M2MTwo.create(name="Two") |
| 107 | await one.two.add(two1, two2) |
| 108 | await one.two.clear() |
| 109 | assert await one.two == [] |
| 110 | assert await two1.one == [] |
| 111 | assert await two2.one == [] |
| 112 | |
| 113 | |
| 114 | @pytest.mark.asyncio |