author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 14 May 2009 11:38:40 +0200 | |
branch | tls-sprint |
changeset 1802 | d628defebc17 |
parent 1398 | 5fe84a5f7035 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
from logilab.common.testlib import TestCase, unittest_main, mock_object |
2 |
||
3 |
from cubicweb.server.session import _make_description |
|
4 |
||
5 |
class Variable: |
|
6 |
def __init__(self, name): |
|
7 |
self.name = name |
|
8 |
self.children = [] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
9 |
|
0 | 10 |
def get_type(self, solution, args=None): |
11 |
return solution[self.name] |
|
12 |
def as_string(self): |
|
13 |
return self.name |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
14 |
|
0 | 15 |
class Function: |
16 |
def __init__(self, name, varname): |
|
17 |
self.name = name |
|
18 |
self.children = [Variable(varname)] |
|
19 |
def get_type(self, solution, args=None): |
|
20 |
return 'Int' |
|
21 |
||
22 |
class MakeDescriptionTC(TestCase): |
|
23 |
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
|
24 |
solution = {'A': 'Int', 'B': 'CWUser'} |
0 | 25 |
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
|
26 |
['Int','CWUser']) |
0 | 27 |
|
28 |
if __name__ == '__main__': |
|
29 |
unittest_main() |