summaryrefslogtreecommitdiff
path: root/tests/generic_relations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generic_relations/tests.py')
-rw-r--r--tests/generic_relations/tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py
index 2402f3d031..5ec1a3f184 100644
--- a/tests/generic_relations/tests.py
+++ b/tests/generic_relations/tests.py
@@ -320,6 +320,30 @@ class GenericRelationsTests(TestCase):
self.assertEqual(1, bacon.tags.count())
self.assertEqual(1, qs.count())
+ def test_clear(self):
+ self.assertSequenceEqual(
+ TaggedItem.objects.order_by('tag'),
+ [self.fatty, self.hairy, self.salty, self.yellow],
+ )
+ self.bacon.tags.clear()
+ self.assertSequenceEqual(self.bacon.tags.all(), [])
+ self.assertSequenceEqual(
+ TaggedItem.objects.order_by('tag'),
+ [self.hairy, self.yellow],
+ )
+
+ def test_remove(self):
+ self.assertSequenceEqual(
+ TaggedItem.objects.order_by('tag'),
+ [self.fatty, self.hairy, self.salty, self.yellow],
+ )
+ self.bacon.tags.remove(self.fatty)
+ self.assertSequenceEqual(self.bacon.tags.all(), [self.salty])
+ self.assertSequenceEqual(
+ TaggedItem.objects.order_by('tag'),
+ [self.hairy, self.salty, self.yellow],
+ )
+
def test_generic_relation_related_name_default(self):
# GenericRelation isn't usable from the reverse side by default.
msg = (