Exemplo n.º 1
0
 def test_task_scheduler_enabled_3(self):
     task = TaskSchedule()
     task.interval = 1
     task.start = datetime.datetime.now()
     task.lastrun = datetime.datetime.now() - datetime.timedelta(
         seconds=task.interval)
     self.assertTrue(task.is_time_to_run())
Exemplo n.º 2
0
#examples: when to discover. when to monitor. when to ...
#will run tasks by sending command (raising event)
'''
import datetime
import time
from helpers.queuehelper import QueueName, QueueEntry
from helpers.taskschedule import TaskSchedule
from backend.fcmapp import ApplicationService

#one-time schedule provision when app starts up
APP = ApplicationService(component='schedule')
APP.startup()
APP.send(QueueName.Q_POOLCONFIGURATIONCHANGED, '')
SLEEP_SECONDS = APP.configuration.get('schedule.sleep.seconds')

HEARTBEAT = TaskSchedule(run_on_init=True)
HEARTBEAT.start = datetime.datetime.now().replace(
    microsecond=0, second=0, minute=0) + datetime.timedelta(hours=1)
HEARTBEAT.interval = 60 * APP.configuration.get('schedule.hearbeat.minutes')

MONITOR = TaskSchedule(run_on_init=True)
MONITOR.interval = APP.configuration.get('schedule.monitor.seconds')

DISCOVER = TaskSchedule(run_on_init=True)
DISCOVER.interval = 60 * APP.configuration.get('schedule.discover.minutes')

CAMERA = TaskSchedule(run_on_init=True)
CAMERA.start = datetime.datetime.now().replace(
    microsecond=0, second=0, minute=0) + datetime.timedelta(hours=1)
CAMERA.interval = 60 * APP.configuration.get('schedule.camera.minutes')
Exemplo n.º 3
0
 def test_task_scheduler_runinit(self):
     task = TaskSchedule(run_on_init=True)
     task.interval = 0
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 4
0
 def test_task_scheduler_disabled(self):
     task = TaskSchedule()
     task.interval = 0
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 5
0
 def test_task_scheduler_enabled(self):
     task = TaskSchedule(run_on_init=True)
     task.interval = 1
     self.assertTrue(task.is_time_to_run())
Exemplo n.º 6
0
 def test_task_scheduler_not_run_yet(self):
     task = TaskSchedule()
     task.interval = 1
     task.start = datetime.datetime.now()
     task.lastrun = datetime.datetime.now()
     self.assertFalse(task.is_time_to_run())
Exemplo n.º 7
0
 def test_task_scheduler_enabled_2(self):
     task = TaskSchedule()
     task.start = datetime.datetime.now()
     task.interval = 1
     task.lastrun = None
     self.assertTrue(task.is_time_to_run())