2012-10-15 10:01:48 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import unittest2
|
|
|
|
|
|
|
|
import openerp
|
2012-10-16 12:54:08 +00:00
|
|
|
from openerp.tools.misc import mute_logger
|
2012-10-15 10:01:48 +00:00
|
|
|
import common
|
|
|
|
|
|
|
|
DB = common.DB
|
|
|
|
ADMIN_USER_ID = common.ADMIN_USER_ID
|
|
|
|
|
2012-11-15 12:39:37 +00:00
|
|
|
def registry():
|
|
|
|
return openerp.modules.registry.RegistryManager.get(DB)
|
2012-10-15 10:01:48 +00:00
|
|
|
|
|
|
|
|
2012-10-16 12:54:08 +00:00
|
|
|
class test_cr_execute(unittest2.TestCase):
|
2012-10-15 10:01:48 +00:00
|
|
|
""" Try cr.execute with wrong parameters """
|
|
|
|
|
2012-10-16 12:54:08 +00:00
|
|
|
@mute_logger('openerp.sql_db')
|
2012-10-15 10:01:48 +00:00
|
|
|
def test_execute_bad_params(self):
|
2012-10-16 12:54:08 +00:00
|
|
|
"""
|
|
|
|
Try to use iterable but non-list or int params in query parameters.
|
|
|
|
"""
|
2012-11-15 12:39:37 +00:00
|
|
|
with registry().cursor(auto_commit=False) as cr:
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
cr.execute("SELECT id FROM res_users WHERE login=%s", 'admin')
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
cr.execute("SELECT id FROM res_users WHERE id=%s", 1)
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
cr.execute("SELECT id FROM res_users WHERE id=%s", '1')
|
2012-10-15 10:01:48 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|