author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Fri, 15 Jan 2010 09:36:49 +0100 | |
branch | stable |
changeset 4245 | ff8e355dbc97 |
parent 4212 | ab6573088b4a |
child 5193 | c9671feff5e2 |
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 |
||
10 |
from cubicweb.server.session import _make_description |
|
11 |
||
12 |
class Variable: |
|
13 |
def __init__(self, name): |
|
14 |
self.name = name |
|
15 |
self.children = [] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
16 |
|
0 | 17 |
def get_type(self, solution, args=None): |
18 |
return solution[self.name] |
|
19 |
def as_string(self): |
|
20 |
return self.name |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
21 |
|
0 | 22 |
class Function: |
23 |
def __init__(self, name, varname): |
|
24 |
self.name = name |
|
25 |
self.children = [Variable(varname)] |
|
26 |
def get_type(self, solution, args=None): |
|
27 |
return 'Int' |
|
28 |
||
29 |
class MakeDescriptionTC(TestCase): |
|
30 |
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
|
31 |
solution = {'A': 'Int', 'B': 'CWUser'} |
0 | 32 |
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
|
33 |
['Int','CWUser']) |
0 | 34 |
|
35 |
if __name__ == '__main__': |
|
36 |
unittest_main() |