2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 16:39:45 +00:00
|
|
|
# Copyright 2023 © AE UTBM
|
|
|
|
# ae@utbm.fr / ae.info@utbm.fr
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 16:39:45 +00:00
|
|
|
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
|
|
|
# https://ae.utbm.fr.
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 16:39:45 +00:00
|
|
|
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 16:39:45 +00:00
|
|
|
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
|
|
|
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
|
|
|
# OR WITHIN THE LOCAL FILE "LICENSE"
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2024-07-09 14:55:07 +00:00
|
|
|
import pytest
|
|
|
|
from django.test import Client
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
from core.models import User
|
|
|
|
from forum.models import Forum, ForumTopic
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.django_db
|
|
|
|
class TestTopicCreation:
|
|
|
|
def test_topic_creation(self, client: Client):
|
|
|
|
user: User = User.objects.get(username="root")
|
|
|
|
forum = Forum.objects.get(name="AE")
|
|
|
|
client.force_login(user)
|
|
|
|
payload = {
|
|
|
|
"title": "Hello IT.",
|
|
|
|
"message": "Have you tried turning it off and on again ?",
|
|
|
|
}
|
|
|
|
assert not ForumTopic.objects.filter(_title=payload["title"]).first()
|
|
|
|
response = client.post(reverse("forum:new_topic", args=str(forum.id)), payload)
|
|
|
|
assert response.status_code == 302
|
|
|
|
topic = ForumTopic.objects.filter(_title=payload["title"]).first()
|
|
|
|
assert topic
|
|
|
|
assert topic.last_message.message == payload["message"]
|