mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Refs #32045 -- Added tests for GenericRelatedObjectManager.clear()/remove().
This commit is contained in:
parent
3f7b327562
commit
6fa3d02f7f
@ -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 = (
|
||||
|
Loading…
Reference in New Issue
Block a user