equal
deleted
inserted
replaced
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """unittest for cubicweb.dbapi""" |
18 """unittest for cubicweb.dbapi""" |
19 |
19 |
20 from __future__ import with_statement |
20 from __future__ import with_statement |
|
21 |
21 from copy import copy |
22 from copy import copy |
22 |
23 |
23 from cubicweb import ConnectionError |
24 from logilab.common import tempattr |
|
25 |
|
26 from cubicweb import ConnectionError, cwconfig |
24 from cubicweb.dbapi import ProgrammingError |
27 from cubicweb.dbapi import ProgrammingError |
25 from cubicweb.devtools.testlib import CubicWebTC |
28 from cubicweb.devtools.testlib import CubicWebTC |
26 |
29 |
27 class DBAPITC(CubicWebTC): |
30 class DBAPITC(CubicWebTC): |
28 |
31 |
65 self.restore_connection() # proper way to close cnx |
68 self.restore_connection() # proper way to close cnx |
66 self.assertRaises(ProgrammingError, cnx.check) |
69 self.assertRaises(ProgrammingError, cnx.check) |
67 self.assertRaises(ProgrammingError, cnx.set_shared_data, 'data', 0) |
70 self.assertRaises(ProgrammingError, cnx.set_shared_data, 'data', 0) |
68 self.assertRaises(ProgrammingError, cnx.get_shared_data, 'data') |
71 self.assertRaises(ProgrammingError, cnx.get_shared_data, 'data') |
69 |
72 |
|
73 def test_web_compatible_request(self): |
|
74 config = cwconfig.CubicWebNoAppConfiguration() |
|
75 with tempattr(self.cnx.vreg, 'config', config): |
|
76 self.cnx.use_web_compatible_requests('http://perdu.com') |
|
77 req = self.cnx.request() |
|
78 self.assertEqual(req.base_url(), 'http://perdu.com') |
|
79 req.ajax_replace_url('domid') # don't crash |
70 |
80 |
71 if __name__ == '__main__': |
81 if __name__ == '__main__': |
72 from logilab.common.testlib import unittest_main |
82 from logilab.common.testlib import unittest_main |
73 unittest_main() |
83 unittest_main() |