mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 10:34:21 +00:00
Apply review suggestions
This commit is contained in:
parent
a8918ebe86
commit
6240eff160
@ -390,7 +390,7 @@ class ForumMessage(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def is_deleted(self):
|
def is_deleted(self):
|
||||||
if self.id is None:
|
if self._state.adding:
|
||||||
return False
|
return False
|
||||||
meta = self.metas.exclude(action="EDIT").order_by("-date").first()
|
meta = self.metas.exclude(action="EDIT").order_by("-date").first()
|
||||||
if meta:
|
if meta:
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from pytest_django.asserts import assertRedirects
|
||||||
|
|
||||||
from core.models import User
|
from core.models import User
|
||||||
from forum.models import Forum, ForumTopic
|
from forum.models import Forum, ForumMessage, ForumTopic
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@ -33,7 +34,13 @@ class TestTopicCreation:
|
|||||||
}
|
}
|
||||||
assert not ForumTopic.objects.filter(_title=payload["title"]).first()
|
assert not ForumTopic.objects.filter(_title=payload["title"]).first()
|
||||||
response = client.post(reverse("forum:new_topic", args=str(forum.id)), payload)
|
response = client.post(reverse("forum:new_topic", args=str(forum.id)), payload)
|
||||||
assert response.status_code == 302
|
assertRedirects(
|
||||||
|
response,
|
||||||
|
expected_url=reverse(
|
||||||
|
"forum:view_message", args=str(ForumMessage.objects.all().count())
|
||||||
|
), # Get the last created message id
|
||||||
|
target_status_code=302,
|
||||||
|
)
|
||||||
topic = ForumTopic.objects.filter(_title=payload["title"]).first()
|
topic = ForumTopic.objects.filter(_title=payload["title"]).first()
|
||||||
assert topic
|
assert topic
|
||||||
assert topic.last_message.message == payload["message"]
|
assert topic.last_message.message == payload["message"]
|
||||||
|
Loading…
Reference in New Issue
Block a user