def test_valid(self): jq = JobQueue(self.db) jq.db['jobqueue'].drop() jq._create(capped=False) self.assertFalse(jq.valid()) self.assertRaises(Exception, jq._create) jq.clear_queue()
def test_publish(self): jq = JobQueue(self.db, collection_name=K.collection) job = {'message': 'hello world!'} jq.pub(job) self.assertEquals(jq.queue_count(), 1) jq.clear_queue() jq.q = None # erase the queue self.assertRaises(Exception, jq.pub, job)
def test_next(self): jq = JobQueue(self.db) self.assertRaises(Exception, jq.next) job = {'message': 'hello world!'} jq.pub(job) row = jq.next() self.assertEquals(row['data']['message'], 'hello world!') jq.clear_queue()
def test_publish(self): jq = JobQueue(self.db) job = {'message': 'hello world!'} jq.pub(job) self.assertEquals(jq.queue_count(), 1) jq.clear_queue() jq.q = None # erase the queue self.assertRaises(Exception, jq.pub, job)
def test_init(self): jq = JobQueue(self.db) self.assertTrue(jq.valid()) self.assertRaises(Exception, jq._create) jq.clear_queue()