mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Add tests for offloading
This commit is contained in:
parent
3e859f7abb
commit
b3e42f5fb0
@ -53,9 +53,31 @@ class ScheduledTaskTests(TestCase):
|
|||||||
self.assertEqual(t.minutes, 5)
|
self.assertEqual(t.minutes, 5)
|
||||||
|
|
||||||
|
|
||||||
|
def get_result():
|
||||||
|
"""Demo function for test_offloading"""
|
||||||
|
return 'abc'
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeTaskTests(TestCase):
|
class InvenTreeTaskTests(TestCase):
|
||||||
"""Unit tests for tasks"""
|
"""Unit tests for tasks"""
|
||||||
|
|
||||||
|
def test_offloading(self):
|
||||||
|
"""Test task offloading"""
|
||||||
|
|
||||||
|
# Run with function ref
|
||||||
|
InvenTree.tasks.offload_task(get_result)
|
||||||
|
|
||||||
|
# Run with string ref
|
||||||
|
InvenTree.tasks.offload_task('InvenTree.test_tasks.get_result')
|
||||||
|
|
||||||
|
# Error runs
|
||||||
|
# Malformed taskname
|
||||||
|
InvenTree.tasks.offload_task('InvenTree')
|
||||||
|
# Non exsistent app
|
||||||
|
InvenTree.tasks.offload_task('InvenTreeABC.test_tasks.doesnotmatter')
|
||||||
|
# Non exsistent function
|
||||||
|
InvenTree.tasks.offload_task('InvenTree.test_tasks.doesnotexsist')
|
||||||
|
|
||||||
def test_task_hearbeat(self):
|
def test_task_hearbeat(self):
|
||||||
"""Test the task heartbeat"""
|
"""Test the task heartbeat"""
|
||||||
InvenTree.tasks.offload_task(InvenTree.tasks.heartbeat)
|
InvenTree.tasks.offload_task(InvenTree.tasks.heartbeat)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user