Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_db_drop_no_existing_database(self):
if v(self.odoo.version) >= v('6.1'):
res = self.odoo.db.drop(ARGS.super_admin_passwd, 'fake_db_name')
self.assertFalse(res)
else:
self.assertRaises(
odoorpc.error.RPCError,
self.odoo.db.drop,
ARGS.super_admin_passwd, 'fake_db_name')
def test_db_drop_no_existing_database(self):
if v(self.odoo.version) >= v('6.1'):
res = self.odoo.db.drop(ARGS.super_admin_passwd, 'fake_db_name')
self.assertFalse(res)
else:
self.assertRaises(
odoorpc.error.RPCError,
self.odoo.db.drop,
ARGS.super_admin_passwd, 'fake_db_name')
def test_browse_with_wrong_id(self):
# Handle exception (execute a 'browse' with wrong ID)
self.assertRaises(
odoorpc.error.RPCError,
self.user_obj.browse, 999999999)
:return: a dictionary (JSON response)
:raise: :class:`odoorpc.error.RPCError`
:raise: `urllib2.HTTPError` (if `params` is not a dictionary)
:raise: `urllib2.URLError` (connection error)
*Python 3:*
:return: a dictionary (JSON response)
:raise: :class:`odoorpc.error.RPCError`
:raise: `urllib.error.HTTPError` (if `params` is not a dictionary)
:raise: `urllib.error.URLError` (connection error)
"""
data = self._connector.proxy_json(url, params)
if data.get('error'):
raise error.RPCError(
data['error']['data']['message'], data['error']
)
return data
def rpc_method(*args):
"""Return the result of the RPC request."""
try:
meth = getattr(self._oerp._connector.wizard, method, False)
return meth(self._oerp.database, self._oerp.user.id, *args)
except rpc.error.ConnectorError as exc:
raise error.RPCError(exc.message, exc.oerp_traceback)
return rpc_method
:return: a dictionary (JSON response)
:raise: :class:`odoorpc.error.RPCError`
:raise: `urllib2.HTTPError` (if `params` is not a dictionary)
:raise: `urllib2.URLError` (connection error)
*Python 3:*
:return: a dictionary (JSON response)
:raise: :class:`odoorpc.error.RPCError`
:raise: `urllib.error.HTTPError` (if `params` is not a dictionary)
:raise: `urllib.error.URLError` (connection error)
"""
data = self._connector.proxy_json(url, params)
if data.get('error'):
raise error.RPCError(
data['error']['data']['message'],
data['error'])
return data
def rpc_method(*args):
"""Return the result of the RPC request."""
try:
meth = getattr(self._oerp._connector.wizard, method, False)
return meth(self._oerp.database, self._oerp.user.id, *args)
except rpc.error.ConnectorError as exc:
raise error.RPCError(exc.message, exc.oerp_traceback)
return rpc_method