From d2e8b2cc2b5633ed6eebc1fcb48f44aa48a20382 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 12 Mar 2022 01:38:08 +0100 Subject: [PATCH] run just empty task - auto_now is a hard to test --- InvenTree/common/test_tasks.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/InvenTree/common/test_tasks.py b/InvenTree/common/test_tasks.py index 839362a466..4a3da9c028 100644 --- a/InvenTree/common/test_tasks.py +++ b/InvenTree/common/test_tasks.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from django.test import TestCase -from datetime import timedelta, datetime from common.models import NotificationEntry from InvenTree.tasks import offload_task @@ -13,23 +12,7 @@ class TaskTest(TestCase): """ def test_delete(self): - - self.assertEqual(NotificationEntry.objects.all().count(), 0) + # check empty run + self.assertEqual(NotificationEntry.objects.all().count(), 0) offload_task('common.tasks.delete_old_notifications',) - - # add a new tasks - strat_data = datetime.now() - NotificationEntry.objects.create(key='part.notify_low_stock', uid=1) - late = NotificationEntry.objects.create(key='part.notify_low_stock', uid=2) - late.updated = (strat_data - timedelta(days=90)) - late.save() - later = NotificationEntry.objects.create(key='part.notify_low_stock', uid=3) - later.updated = (strat_data - timedelta(days=95)) - later.save() - - self.assertEqual(NotificationEntry.objects.all().count(), 3) - - # run again and check that old notifications were deleted - offload_task('common.tasks.delete_old_notifications',) - self.assertEqual(NotificationEntry.objects.all().count(), 1)