Skip to content

Commit

Permalink
Improve tag filter test on Post
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Jan 4, 2023
1 parent 6316acd commit 7085627
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion democracy_club/apps/hermes/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ def test_context_contains_posts(self):

def test_qs_contains_tags(self):
"""The PostListView can filter tags if requested"""

self.post1.tags.append("foo")
self.post1.save()

self.post2.tags.append("foo")
self.post2.save()

self.post3.tags.append("bar")
self.post3.save()

response = self.get(self.url() + "?tag=foo")
expected = list(models.Post.objects.published().for_tag("foo"))
expected = list(models.Post.objects.published().filter(tags=["foo"]))
self.assertEqual(expected, list(response.context["posts"]))
self.assertContains(response, self.post1.subject)
self.assertNotContains(response, self.post3.subject)


class ArchivePostListViewTestCase(HermesTestCase):
Expand Down

0 comments on commit 7085627

Please sign in to comment.