Skip to content

Commit

Permalink
simplify test_unanswered_order test
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Dec 17, 2024
1 parent e7c826c commit 2cbbd3e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lacommunaute/forum_conversation/tests/tests_models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from datetime import datetime, timezone

import pytest
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.test import TestCase
from django.urls import reverse
from factory import Iterator

from lacommunaute.forum.factories import ForumFactory
from lacommunaute.forum_conversation.factories import (
Expand Down Expand Up @@ -53,12 +50,10 @@ def test_unanswered(self):

def test_unanswered_order(self):
forum = ForumFactory()
last_post_dates = [datetime(2025, 5, i, tzinfo=timezone.utc) for i in range(20, 24)]

TopicFactory.create_batch(
size=len(last_post_dates), forum=forum, posts_count=1, last_post_on=Iterator(last_post_dates)
)
assert list(Topic.objects.unanswered().values_list("last_post_on", flat=True)) == last_post_dates[::-1]
topics = TopicFactory.create_batch(size=3, forum=forum, with_post=True)
expected_date_list = [topic.last_post_on for topic in topics[::-1]]
extracted_date_list = list(Topic.objects.unanswered().values_list("last_post_on", flat=True))
assert extracted_date_list == expected_date_list

def test_optimized_for_topics_list_disapproved(self):
TopicFactory(approved=False)
Expand Down

0 comments on commit 2cbbd3e

Please sign in to comment.