author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 20 Apr 2010 15:55:50 +0200 | |
changeset 5352 | be44c58d3ed9 |
parent 5197 | 98dc05495e3e |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
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:
1802
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:
1802
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:
1802
diff
changeset
|
7 |
""" |
0 | 8 |
from logilab.common.testlib import TestCase, unittest_main, mock_object |
9 |
||
5193
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
10 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 11 |
from cubicweb.server.session import _make_description |
12 |
||
13 |
class Variable: |
|
14 |
def __init__(self, name): |
|
15 |
self.name = name |
|
16 |
self.children = [] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
17 |
|
0 | 18 |
def get_type(self, solution, args=None): |
19 |
return solution[self.name] |
|
20 |
def as_string(self): |
|
21 |
return self.name |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
22 |
|
0 | 23 |
class Function: |
24 |
def __init__(self, name, varname): |
|
25 |
self.name = name |
|
26 |
self.children = [Variable(varname)] |
|
27 |
def get_type(self, solution, args=None): |
|
28 |
return 'Int' |
|
29 |
||
30 |
class MakeDescriptionTC(TestCase): |
|
31 |
def test_known_values(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
32 |
solution = {'A': 'Int', 'B': 'CWUser'} |
0 | 33 |
self.assertEquals(_make_description((Function('max', 'A'), Variable('B')), {}, solution), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
34 |
['Int','CWUser']) |
0 | 35 |
|
5193
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
36 |
class InternalSessionTC(CubicWebTC): |
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
37 |
def test_dbapi_query(self): |
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
38 |
session = self.repo.internal_session() |
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
39 |
self.assertFalse(session.running_dbapi_query) |
5197
98dc05495e3e
[test] properly close session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5193
diff
changeset
|
40 |
session.close() |
5193
c9671feff5e2
[session] no way for queries from an InternalSession to be a dbapi query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
41 |
|
0 | 42 |
if __name__ == '__main__': |
43 |
unittest_main() |