def test_retries_if_no_transaction_found(self): raw_task = self.mock_task() raw_task.side_effect = AssertionError("Shouldn't be called!") task = worker.task(wait_for_transaction(raw_task), bind=True) transaction_id = uuid.uuid4() assert_raises(Retry, lambda: task(transaction_id))
def test_runs_if_transaction_found(self): raw_task = self.mock_task() task = worker.task(wait_for_transaction(raw_task), bind=True) transaction_id = TaskTransaction.new_id() task(transaction_id) raw_task.assert_called_once_with(task)
def test_transaction_is_deleted_after_running(self): raw_task = self.mock_task() task = worker.task(wait_for_transaction(raw_task), bind=True) transaction_id = TaskTransaction.new_id() task(transaction_id) transactions = Client().session().query(TaskTransaction).all() eq_(transactions, [])
def test_only_deletes_appropriate_transaction(self): raw_task = self.mock_task() task = worker.task(wait_for_transaction(raw_task), bind=True) transaction_id = TaskTransaction.new_id() other_transaction_id = TaskTransaction.new_id() task(transaction_id) session = Client().session() transaction_ids = session.query(TaskTransaction.transaction_id).all() eq_(transaction_ids, [(other_transaction_id,)])