Skip to content

Commit f6194b7

Browse files
committed
Add test for deleting model's objects
1 parent 95defc5 commit f6194b7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_model.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ def test_update_model():
6060
assert SimpleModel.objects.count() == 1
6161

6262

63+
def test_delete_from_model():
64+
with captured_queries(connection) as ctx:
65+
assert SimpleModel.objects.count() == 0
66+
SimpleModel.objects.create()
67+
SimpleModel.refresh()
68+
69+
assert SimpleModel.objects.count() == 1
70+
SimpleModel.objects.all().delete()
71+
assert ctx.latest_query.stmt == 'DELETE FROM "test_app_simplemodel"'
72+
73+
74+
SimpleModel.refresh()
75+
assert SimpleModel.objects.count() == 0
76+
6377
def test_insert_all_fields():
6478
"""Test that an object is created and accounted for with all supported field types"""
6579

0 commit comments

Comments
 (0)