Skip to content

Commit

Permalink
Refs #26678 -- Added explicit test for add/remove by pk
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Apr 17, 2019
1 parent 684c7ee commit afd0b52
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/many_to_many/tests.py
Expand Up @@ -76,6 +76,16 @@ def test_add(self):
]
)

def test_add_and_remove_by_value(self):
a5 = Article.objects.create(headline='Django lets you create Web apps easily')
a5.publications.add(self.p1.pk)
self.assertQuerysetEqual(
a5.publications.all(),
['<Publication: The Python Journal>'],
)
self.p1.article_set.remove(a5.pk)
self.assertQuerysetEqual(a5.publications.all(), [])

def test_reverse_add(self):
# Adding via the 'other' end of an m2m
a5 = Article(headline='NASA finds intelligent life on Mars')
Expand Down

0 comments on commit afd0b52

Please sign in to comment.