diff --git a/lacommunaute/forum_conversation/tests/tests_models.py b/lacommunaute/forum_conversation/tests/tests_models.py index 25fab242..cbcec909 100644 --- a/lacommunaute/forum_conversation/tests/tests_models.py +++ b/lacommunaute/forum_conversation/tests/tests_models.py @@ -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 ( @@ -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)