mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +00:00
extend tests for task_delete_succ
This commit is contained in:
parent
eb24bf78b8
commit
2ec59a6ad2
@ -2,6 +2,9 @@
|
|||||||
Unit tests for task management
|
Unit tests for task management
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
from django.utils import timezone
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django_q.models import Schedule
|
from django_q.models import Schedule
|
||||||
|
|
||||||
@ -52,7 +55,19 @@ class InvenTreeTaskTests(TestCase):
|
|||||||
|
|
||||||
def test_task_delete_successful_tasks(self):
|
def test_task_delete_successful_tasks(self):
|
||||||
"""Test the task delete_successful_tasks"""
|
"""Test the task delete_successful_tasks"""
|
||||||
|
from django_q.models import Success
|
||||||
|
|
||||||
|
Success.objects.create(
|
||||||
|
name='abc',
|
||||||
|
func='abc',
|
||||||
|
started=timezone.now() - timedelta(days=31)
|
||||||
|
)
|
||||||
InvenTree.tasks.offload_task(InvenTree.tasks.delete_successful_tasks)
|
InvenTree.tasks.offload_task(InvenTree.tasks.delete_successful_tasks)
|
||||||
|
threshold = timezone.now() - timedelta(days=30)
|
||||||
|
results = Success.objects.filter(
|
||||||
|
started__lte=threshold
|
||||||
|
)
|
||||||
|
self.assertEqual(len(results, 0))
|
||||||
|
|
||||||
def test_task_delete_old_error_logs(self):
|
def test_task_delete_old_error_logs(self):
|
||||||
"""Test the task delete_old_error_logs"""
|
"""Test the task delete_old_error_logs"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user