author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 20 Apr 2010 18:34:37 +0200 | |
changeset 5364 | e0feefb87de5 |
parent 5223 | 6abd6e3599f4 |
child 5423 | e15abfdcce38 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
7 |
""" |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
8 |
from __future__ import with_statement |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
9 |
from copy import copy |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
10 |
|
0 | 11 |
from cubicweb import ConnectionError |
12 |
from cubicweb.dbapi import ProgrammingError |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
13 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 14 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
15 |
class DBAPITC(CubicWebTC): |
0 | 16 |
|
17 |
def test_public_repo_api(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
18 |
cnx = self.login('anon') |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
19 |
self.assertEquals(cnx.get_schema(), self.repo.schema) |
0 | 20 |
self.assertEquals(cnx.source_defs(), {'system': {'adapter': 'native', 'uri': 'system'}}) |
21 |
self.restore_connection() # proper way to close cnx |
|
22 |
self.assertRaises(ProgrammingError, cnx.get_schema) |
|
23 |
self.assertRaises(ProgrammingError, cnx.source_defs) |
|
24 |
||
25 |
def test_db_api(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
26 |
cnx = self.login('anon') |
0 | 27 |
self.assertEquals(cnx.rollback(), None) |
28 |
self.assertEquals(cnx.commit(), None) |
|
29 |
self.restore_connection() # proper way to close cnx |
|
30 |
#self.assertEquals(cnx.close(), None) |
|
31 |
self.assertRaises(ProgrammingError, cnx.rollback) |
|
32 |
self.assertRaises(ProgrammingError, cnx.commit) |
|
33 |
self.assertRaises(ProgrammingError, cnx.close) |
|
34 |
||
35 |
def test_api(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
36 |
cnx = self.login('anon') |
0 | 37 |
self.assertEquals(cnx.user(None).login, 'anon') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
38 |
self.assertEquals(cnx.describe(1), (u'CWGroup', u'system', None)) |
0 | 39 |
self.restore_connection() # proper way to close cnx |
4768
430b89aed996
delete pyro proxy on connection close, properly raise programming error when working on a closed connection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
40 |
self.assertRaises(ProgrammingError, cnx.user, None) |
430b89aed996
delete pyro proxy on connection close, properly raise programming error when working on a closed connection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
41 |
self.assertRaises(ProgrammingError, cnx.describe, 1) |
0 | 42 |
|
43 |
def test_shared_data_api(self): |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
44 |
cnx = self.login('anon') |
0 | 45 |
self.assertEquals(cnx.get_shared_data('data'), None) |
46 |
cnx.set_shared_data('data', 4) |
|
47 |
self.assertEquals(cnx.get_shared_data('data'), 4) |
|
48 |
cnx.get_shared_data('data', pop=True) |
|
49 |
cnx.get_shared_data('whatever', pop=True) |
|
50 |
self.assertEquals(cnx.get_shared_data('data'), None) |
|
51 |
cnx.set_shared_data('data', 4) |
|
52 |
self.assertEquals(cnx.get_shared_data('data'), 4) |
|
53 |
self.restore_connection() # proper way to close cnx |
|
4768
430b89aed996
delete pyro proxy on connection close, properly raise programming error when working on a closed connection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
54 |
self.assertRaises(ProgrammingError, cnx.check) |
430b89aed996
delete pyro proxy on connection close, properly raise programming error when working on a closed connection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
55 |
self.assertRaises(ProgrammingError, cnx.set_shared_data, 'data', 0) |
430b89aed996
delete pyro proxy on connection close, properly raise programming error when working on a closed connection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
56 |
self.assertRaises(ProgrammingError, cnx.get_shared_data, 'data') |
0 | 57 |
|
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
58 |
|
0 | 59 |
if __name__ == '__main__': |
60 |
from logilab.common.testlib import unittest_main |
|
61 |
unittest_main() |