def test_peek_queued(self): engine = temp_db.get_temp_db() t_db = TransactionDB(engine) tr_1 = self._get_test_transaction() t_id_1 = t_db.create_transaction(tr_1) t_db.set_queued(t_id_1, '', 'wait') tr_2 = self._get_test_transaction() # just in case t_id_2 = t_db.create_transaction(tr_2) t_db.set_queued(t_id_2, '', 'wait') self.assertFalse(t_db.peek_queued('non_wait')) t = t_db.peek_queued('wait') self.assertEquals(t.transaction_id, t_id_1) t = t_db.peek_queued('wait') self.assertEquals(t.transaction_id, t_id_1) t_db.set_processing(t_id_1, 'spm', '', 50) t = t_db.peek_queued('wait') self.assertEquals(t.transaction_id, t_id_2) t_db.close()
def test_peek_queued_all(self): engine = temp_db.get_temp_db() t_db = TransactionDB(engine) tr_1 = self._get_test_transaction() t_id_1 = t_db.create_transaction(tr_1) t_db.set_queued(t_id_1, '', 'wait') tr_2 = self._get_test_transaction() # just in case t_id_2 = t_db.create_transaction(tr_2) t_db.set_queued(t_id_2, '', 'wait') lt = list(t_db.peek_queued('wait', peek_all=True)) self.assertEqual(2, len(lt)) self.assertEqual([tr_1, tr_2], lt) t_db.close()