From bc4cc21ec9b491f6bfe731daefa6636aa126a7af Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 25 Nov 2024 12:03:53 +0100 Subject: [PATCH] I want a more romantic test --- lacommunaute/forum_conversation/tests/tests_models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lacommunaute/forum_conversation/tests/tests_models.py b/lacommunaute/forum_conversation/tests/tests_models.py index f510b566..22556d37 100644 --- a/lacommunaute/forum_conversation/tests/tests_models.py +++ b/lacommunaute/forum_conversation/tests/tests_models.py @@ -1,3 +1,5 @@ +from datetime import datetime, timezone + from django.conf import settings from django.core.exceptions import ValidationError from django.db import IntegrityError @@ -50,14 +52,12 @@ def test_unanswered(self): def test_unanswered_order(self): forum = ForumFactory() - last_post_dates = ["2024-05-17", "2024-05-23", "2024-09-22"] + last_post_dates = [datetime(2025, 5, i, tzinfo=timezone.utc) for i in range(20, 24)] - topics = TopicFactory.create_batch( + TopicFactory.create_batch( size=len(last_post_dates), forum=forum, posts_count=1, last_post_on=Iterator(last_post_dates) ) - unanswered_topics = Topic.objects.unanswered() - self.assertEqual(unanswered_topics.first(), topics[-1]) - self.assertEqual(unanswered_topics.last(), topics[0]) + assert list(Topic.objects.unanswered().values_list("last_post_on", flat=True)) == last_post_dates[::-1] def test_optimized_for_topics_list_disapproved(self): TopicFactory(approved=False)