Skip to content

Commit

Permalink
wip test
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Jul 3, 2023
1 parent e139ae9 commit ddb20b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
26 changes: 26 additions & 0 deletions lacommunaute/pages/tests/test_homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest # noqa
from django.urls import reverse

from lacommunaute.forum.enums import Kind as ForumKind
from lacommunaute.forum.factories import ForumFactory
from lacommunaute.forum_conversation.factories import TopicFactory


def test_context_data(client, db):
topic = TopicFactory(with_post=True, forum=ForumFactory())
news = TopicFactory(with_post=True, forum=ForumFactory(kind=ForumKind.NEWS))
article = ForumFactory(parent=ForumFactory(type=1))

disapproved_topic = TopicFactory(with_post=True, forum=ForumFactory())
disapproved_topic.approved = False
disapproved_topic.save()
TopicFactory(with_post=True, forum=ForumFactory(kind=ForumKind.PRIVATE_FORUM))

url = reverse("pages:home")

response = client.get(url)
assert response.status_code == 200

assert response.context_data["topics_public"].get() == topic
assert response.context_data["topics_newsfeed"].get() == news
assert response.context_data["forums_category"].get() == article
8 changes: 0 additions & 8 deletions lacommunaute/pages/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
assign_perm = get_class("forum_permission.shortcuts", "assign_perm")


class HomepageTest(TestCase):
def test_home_page(self):
url = reverse("pages:home")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "pages/home.html")


class StatistiquesPageTest(TestCase):
def test_context_data(self):
url = reverse("pages:statistiques")
Expand Down

0 comments on commit ddb20b5

Please sign in to comment.