项目作者: primary-student
项目描述 :
This is a python testing framework used to verify whether the scheduled task will execute as expected at the scheduled time.
高级语言:
项目地址: git://github.com/primary-student/scheduled_task_verification_framework.git
scheduled_task_verification_framework
This is a python testing framework used to verify whether the scheduled task will execute as expected at the scheduled time.
It has been personally tested on centos7.
Usage
Way 1: Explicitly add decorators to your scheduled method. (See “Example\Example 1 Using decorator on task-func.py“ for the complete code)
from apscheduler.schedulers.background import BackgroundScheduler
from scheduled_task_verification_framework import scheduler_task_manager
scheduler_task_manager_obj = scheduler_task_manager()
@scheduler_task_manager_obj.is_cronTask(name = "monday",task_scheduled_run_at = now_is_monday)
def task_on_every_monday():
print("Running task [task_on_every_monday], %s" %strftime("%Y-%m-%d-%H_%M_%S", localtime()))
scheduler = BackgroundScheduler()
scheduler.add_job(task_on_every_monday, 'cron',day_of_week="mon", hour=1, minute=1)
scheduler.start()
scheduler_task_manager_obj.monitor(……)
Way 2: Create a new method with hook instead of the old scheduled method. (See “Example\Example 2 Run new task func instead of old.py“ for the complete code)
from apscheduler.schedulers.background import BackgroundScheduler
from scheduled_task_verification_framework import scheduler_task_manager
scheduler_task_manager_obj = scheduler_task_manager()
def task_on_every_monday():
print("Running task [task_on_every_monday], %s" %strftime("%Y-%m-%d-%H_%M_%S", localtime()))
new_task_on_every_monday = scheduler_task_manager_obj.is_cronTask(name = "monday",task_scheduled_run_at = now_is_monday)(task_on_every_monday)
scheduler.add_job(new_task_on_every_monday, 'cron',day_of_week="mon", hour=1, minute=1)
scheduler.start()
scheduler_task_manager_obj.monitor(……)