mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 05:26:45 +00:00
add checks for old_error_log
This commit is contained in:
parent
f3c4720f5b
commit
09bda7e516
@ -8,10 +8,16 @@ 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
|
||||||
|
|
||||||
|
from error_report.models import Error
|
||||||
|
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
from common.models import InvenTreeSetting
|
from common.models import InvenTreeSetting
|
||||||
|
|
||||||
|
|
||||||
|
threshold = timezone.now() - timedelta(days=30)
|
||||||
|
threshold_low = threshold - timedelta(days=1)
|
||||||
|
|
||||||
|
|
||||||
class ScheduledTaskTests(TestCase):
|
class ScheduledTaskTests(TestCase):
|
||||||
"""
|
"""
|
||||||
Unit tests for scheduled tasks
|
Unit tests for scheduled tasks
|
||||||
@ -72,8 +78,23 @@ class InvenTreeTaskTests(TestCase):
|
|||||||
|
|
||||||
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"""
|
||||||
|
|
||||||
|
# Create error
|
||||||
|
error_obj = Error.objects.create()
|
||||||
|
error_obj.when = threshold_low
|
||||||
|
error_obj.save()
|
||||||
|
|
||||||
|
# Check that it is not empty
|
||||||
|
errors = Error.objects.filter(when__lte=threshold,)
|
||||||
|
self.assertNotEqual(len(errors), 0)
|
||||||
|
|
||||||
|
# Run action
|
||||||
InvenTree.tasks.offload_task(InvenTree.tasks.delete_old_error_logs)
|
InvenTree.tasks.offload_task(InvenTree.tasks.delete_old_error_logs)
|
||||||
|
|
||||||
|
# Check that it is empty again
|
||||||
|
errors = Error.objects.filter(when__lte=threshold,)
|
||||||
|
self.assertEqual(len(errors), 0)
|
||||||
|
|
||||||
def test_task_check_for_updates(self):
|
def test_task_check_for_updates(self):
|
||||||
"""Test the task check_for_updates"""
|
"""Test the task check_for_updates"""
|
||||||
# Check that setting should be empty
|
# Check that setting should be empty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user