Coverage for src/backend/InvenTree/plugin/samples/integration/scheduled_task.py: 0%

17 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 17:47 +0000

1"""Sample plugin which supports task scheduling.""" 

2 

3from plugin import InvenTreePlugin 

4from plugin.mixins import ScheduleMixin, SettingsMixin 

5 

6 

7# Define some simple tasks to perform 

8def print_hello(): 

9 """Sample function that can be called on schedule. 

10 

11 Contents do not matter - therefore no coverage. 

12 """ 

13 print('Hello') # pragma: no cover 

14 

15 

16def print_world(): 

17 """Sample function that can be called on schedule. 

18 

19 Contents do not matter - therefore no coverage. 

20 """ 

21 print('World') # pragma: no cover 

22 

23 

24class ScheduledTaskPlugin(ScheduleMixin, SettingsMixin, InvenTreePlugin): 

25 """A sample plugin which provides support for scheduled tasks.""" 

26 

27 NAME = 'ScheduledTasksPlugin' 

28 SLUG = 'schedule' 

29 TITLE = 'Scheduled Tasks' 

30 VERSION = '0.2.0' 

31 

32 SCHEDULED_TASKS = { 

33 'member': {'func': 'member_func', 'schedule': 'I', 'minutes': 30}, 

34 'hello': { 

35 'func': 'plugin.samples.integration.scheduled_task.print_hello', 

36 'schedule': 'I', 

37 'minutes': 45, 

38 }, 

39 'world': { 

40 'func': 'plugin.samples.integration.scheduled_task.print_world', 

41 'schedule': 'H', 

42 }, 

43 } 

44 

45 SETTINGS = { 

46 'T_OR_F': { 

47 'name': 'True or False', 

48 'description': 'Print true or false when running the periodic task', 

49 'validator': bool, 

50 'default': False, 

51 } 

52 } 

53 

54 def member_func(self, *args, **kwargs): 

55 """A simple member function to demonstrate functionality.""" 

56 t_or_f = self.get_setting('T_OR_F') 

57 

58 print(f'Called member_func - value is {t_or_f}') 

59 return t_or_f