Fix the tests and the one bug that it highlighted.

This commit is contained in:
jakedt 2014-02-16 18:59:24 -05:00
parent b619356907
commit e7064f1191
6 changed files with 53 additions and 24 deletions

View file

@ -1,6 +1,10 @@
from datetime import datetime, timedelta
from data.database import QueueItem, db
from app import app
transaction_factory = app.config['DB_TRANSACTION_FACTORY']
class WorkQueue(object):
@ -34,7 +38,7 @@ class WorkQueue(object):
available_or_expired = ((QueueItem.available == True) |
(QueueItem.processing_expires <= now))
with db.transaction():
with transaction_factory(db):
avail = QueueItem.select().where(QueueItem.queue_name == self.queue_name,
QueueItem.available_after <= now,
available_or_expired,