mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	extend tests for task_delete_succ
This commit is contained in:
		| @@ -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""" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user