server/test/unittest_session.py
changeset 0 b97547f5f1fa
child 1398 5fe84a5f7035
equal deleted inserted replaced
-1:000000000000 0:b97547f5f1fa
       
     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):
       
    24         solution = {'A': 'Int', 'B': 'EUser'}
       
    25         self.assertEquals(_make_description((Function('max', 'A'), Variable('B')), {}, solution),
       
    26                           ['Int','EUser'])
       
    27 
       
    28 if __name__ == '__main__':
       
    29     unittest_main()