author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 21 May 2010 18:40:26 +0200 | |
changeset 5574 | e082a57c2207 |
parent 5426 | 0d4853a6e5ee |
child 6340 | 470d8e828fda |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
18 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
19 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
20 |
""" |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
21 |
from __future__ import with_statement |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
22 |
from copy import copy |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
23 |
|
0 | 24 |
from cubicweb import ConnectionError |
25 |
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
|
26 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 27 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
28 |
class DBAPITC(CubicWebTC): |
0 | 29 |
|
30 |
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
|
31 |
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
|
32 |
self.assertEquals(cnx.get_schema(), self.repo.schema) |
0 | 33 |
self.assertEquals(cnx.source_defs(), {'system': {'adapter': 'native', 'uri': 'system'}}) |
34 |
self.restore_connection() # proper way to close cnx |
|
35 |
self.assertRaises(ProgrammingError, cnx.get_schema) |
|
36 |
self.assertRaises(ProgrammingError, cnx.source_defs) |
|
37 |
||
38 |
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
|
39 |
cnx = self.login('anon') |
0 | 40 |
self.assertEquals(cnx.rollback(), None) |
41 |
self.assertEquals(cnx.commit(), None) |
|
42 |
self.restore_connection() # proper way to close cnx |
|
43 |
#self.assertEquals(cnx.close(), None) |
|
44 |
self.assertRaises(ProgrammingError, cnx.rollback) |
|
45 |
self.assertRaises(ProgrammingError, cnx.commit) |
|
46 |
self.assertRaises(ProgrammingError, cnx.close) |
|
47 |
||
48 |
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
|
49 |
cnx = self.login('anon') |
0 | 50 |
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
|
51 |
self.assertEquals(cnx.describe(1), (u'CWGroup', u'system', None)) |
0 | 52 |
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
|
53 |
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
|
54 |
self.assertRaises(ProgrammingError, cnx.describe, 1) |
0 | 55 |
|
56 |
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
|
57 |
cnx = self.login('anon') |
0 | 58 |
self.assertEquals(cnx.get_shared_data('data'), None) |
59 |
cnx.set_shared_data('data', 4) |
|
60 |
self.assertEquals(cnx.get_shared_data('data'), 4) |
|
61 |
cnx.get_shared_data('data', pop=True) |
|
62 |
cnx.get_shared_data('whatever', pop=True) |
|
63 |
self.assertEquals(cnx.get_shared_data('data'), None) |
|
64 |
cnx.set_shared_data('data', 4) |
|
65 |
self.assertEquals(cnx.get_shared_data('data'), 4) |
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
self.assertRaises(ProgrammingError, cnx.get_shared_data, 'data') |
0 | 70 |
|
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4768
diff
changeset
|
71 |
|
0 | 72 |
if __name__ == '__main__': |
73 |
from logilab.common.testlib import unittest_main |
|
74 |
unittest_main() |