author | sylvain.thenault@logilab.fr |
Wed, 29 Apr 2009 09:03:31 +0200 | |
branch | tls-sprint |
changeset 1530 | 849fd3d64f11 |
parent 1398 | 5fe84a5f7035 |
child 1802 | d628defebc17 |
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 = [] |
|
9 |
||
10 |
def get_type(self, solution, args=None): |
|
11 |
return solution[self.name] |
|
12 |
def as_string(self): |
|
13 |
return self.name |
|
14 |
||
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() |