Skip to content

Commit

Permalink
make test resilient againts linter reindentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Oct 2, 2023
1 parent a745c63 commit 646d2f2
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions lacommunaute/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from django.template.defaultfilters import truncatechars_html
from django.test import RequestFactory, TestCase
from django.urls import reverse
Expand Down Expand Up @@ -368,34 +370,36 @@ def test_upvote_actions(self):
self.client.force_login(self.user)
no_upvote_html = (
'<button type="submit"'
'\n title="Sauvegarder"'
'\n class="btn btn-sm btn-ico btn-secondary matomo-event px-2"'
'\n data-matomo-category="engagement"'
'\n data-matomo-action="upvote"'
'\n data-matomo-option="post"'
"\n >"
'\n <i class="ri-bookmark-line me-1" aria-hidden="true"></i>'
' title="Sauvegarder"'
' class="btn btn-sm btn-ico btn-secondary matomo-event px-2"'
' data-matomo-category="engagement"'
' data-matomo-action="upvote"'
' data-matomo-option="post"'
" >"
' <i class="ri-bookmark-line me-1" aria-hidden="true"></i>'
"<span>0</span>"
)
response = self.client.get(reverse("forum_extension:forum", kwargs={"pk": child_forum.pk, "slug": forum.slug}))
self.assertContains(response, no_upvote_html, status_code=200)
self.assertEqual(response.status_code, 200)
self.assertIn(no_upvote_html, re.sub(r"\s+", " ", response.content.decode("utf-8")))

child_forum.upvotes.create(voter=self.user)
upvoted_html = (
'<button type="submit"'
'\n title="Sauvegarder"'
'\n class="btn btn-sm btn-ico btn-secondary matomo-event px-2"'
'\n data-matomo-category="engagement"'
'\n data-matomo-action="upvote"'
'\n data-matomo-option="post"'
"\n >"
'\n <i class="ri-bookmark-fill me-1" aria-hidden="true"></i>'
' title="Sauvegarder"'
' class="btn btn-sm btn-ico btn-secondary matomo-event px-2"'
' data-matomo-category="engagement"'
' data-matomo-action="upvote"'
' data-matomo-option="post"'
" >"
' <i class="ri-bookmark-fill me-1" aria-hidden="true"></i>'
"<span>1</span>"
)
response = self.client.get(
reverse("forum_extension:forum", kwargs={"pk": child_forum.pk, "slug": child_forum.slug})
)
self.assertContains(response, upvoted_html, status_code=200)
self.assertEqual(response.status_code, 200)
self.assertIn(upvoted_html, re.sub(r"\s+", " ", response.content.decode("utf-8")))

def test_upvotes_count(self):
forum = CategoryForumFactory(with_public_perms=True, with_child=True)
Expand Down

0 comments on commit 646d2f2

Please sign in to comment.