server/test/unittest_session.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 15 May 2009 14:00:43 +0200
branchstable
changeset 1828 e9e8beb06f01
parent 1802 d628defebc17
child 1977 606923dff11b
permissions -rw-r--r--
[treeview] really fix #343232

from logilab.common.testlib import TestCase, unittest_main, mock_object

from cubicweb.server.session import _make_description

class Variable:
    def __init__(self, name):
        self.name = name
        self.children = []

    def get_type(self, solution, args=None):
        return solution[self.name]
    def as_string(self):
        return self.name

class Function:
    def __init__(self, name, varname):
        self.name = name
        self.children = [Variable(varname)]
    def get_type(self, solution, args=None):
        return 'Int'

class MakeDescriptionTC(TestCase):
    def test_known_values(self):
        solution = {'A': 'Int', 'B': 'CWUser'}
        self.assertEquals(_make_description((Function('max', 'A'), Variable('B')), {}, solution),
                          ['Int','CWUser'])

if __name__ == '__main__':
    unittest_main()