def __init__(self, queue, result_store=None, schedule=None, events=None, store_none=False, always_eager=False): self.queue = queue self.result_store = result_store self.schedule = schedule or DummySchedule(self.queue.name) self.events = events self.blocking = self.queue.blocking self.store_none = store_none self.always_eager = always_eager
import unittest from huey import crontab from huey import exceptions as huey_exceptions from huey import Huey from huey.api import QueueTask from huey.backends.dummy import DummyDataStore from huey.backends.dummy import DummyQueue from huey.backends.dummy import DummySchedule from huey.registry import registry from huey.utils import EmptyData from huey.utils import local_to_utc queue_name = 'test-queue' queue = DummyQueue(queue_name) schedule = DummySchedule(queue_name) huey = Huey(queue, schedule=schedule) res_queue_name = 'test-queue-2' res_queue = DummyQueue(res_queue_name) res_store = DummyDataStore(res_queue_name) res_huey = Huey(res_queue, res_store, schedule) res_huey_nones = Huey(res_queue, res_store, store_none=True) # store some global state state = {} # create a decorated queue command @huey.task()
from contextlib import contextmanager import unittest from huey import Huey from huey.backends.dummy import DummyDataStore from huey.backends.dummy import DummyQueue from huey.backends.dummy import DummySchedule from huey.peewee_helpers import db_periodic_task from huey.peewee_helpers import db_task from peewee import * queue = DummyQueue('test-queue') schedule = DummySchedule('test-queue') data_store = DummyDataStore('test-queue') huey = Huey(queue, data_store, schedule=schedule) STATE = [] class MockSqliteDatabase(SqliteDatabase): def record_call(fn): def inner(*args, **kwargs): STATE.append(fn.__name__) return fn(*args, **kwargs) return inner connect = record_call(SqliteDatabase.connect) close = record_call(SqliteDatabase.close) transaction = record_call(SqliteDatabase.transaction)