def _manage_errors(self, errors): message = u"" if errors: for error in errors: message = u"{}\n{}:\n{}\n".format(message, error["code"], error["message"]) raise TransactionException(200, message)
def _request(self, url, statements=None): if statements is None: statements = [] request = Request(**self._class._auth) data = {"statements": statements} response = request.post(url, data=data) if response.status_code in [200, 201]: return response else: raise TransactionException(response.status_code)
def rollback(self): if self.url_tx: request = Request(**self._class._auth) response = request.delete(self.url_tx) if response.status_code in [200, 201]: self._manage_errors(response.json()["errors"]) self.finished = True for reference in self.executed: obj = reference["obj"] if obj is not None: obj._elements = [] obj.columns = None self.executed = [] else: raise TransactionException(response.status_code)
def test_transaction_params(self): TransactionException(200, "Message")
def test_transaction_exception(self): TransactionException()