From 09e21f7e5b21825b5d04350bc51ed2f7084366b4 Mon Sep 17 00:00:00 2001 From: Laetitia Getti Date: Fri, 17 Mar 2023 17:39:25 +0100 Subject: [PATCH] fonction is_ongoing et tests --- la_chariotte/order/models.py | 2 ++ la_chariotte/order/tests.py | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py index 4c4881f..0a3033b 100644 --- a/la_chariotte/order/models.py +++ b/la_chariotte/order/models.py @@ -1,3 +1,5 @@ +import datetime + from django.db import models from django.utils import timezone diff --git a/la_chariotte/order/tests.py b/la_chariotte/order/tests.py index 7ce503c..37453f1 100644 --- a/la_chariotte/order/tests.py +++ b/la_chariotte/order/tests.py @@ -1,3 +1,25 @@ -from django.test import TestCase +import datetime + +from django.test import TestCase +from django.utils import timezone +from .models import Grouped_order + + +class GroupedOrderModelTests(TestCase): + + def test_is_ongoing_with_ongoing_grouped_order(self): + """ + is_ongoing() returns True if the deadline is not crossed + """ + deadline = timezone.now() + datetime.timedelta(days=10) + ongoing_gr_order = Grouped_order(deadline=deadline) + self.assertIs(ongoing_gr_order.is_ongoing(), True) + + def test_is_ongoing_with_old_grouped_order(self): + """ + is_ongoing() returns False if the deadline is crossed + """ + deadline = timezone.now() - datetime.timedelta(hours=1) + ongoing_gr_order = Grouped_order(deadline=deadline) + self.assertIs(ongoing_gr_order.is_ongoing(), False) -# Create your tests here.