server/test/unittest_session.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 25 May 2009 16:11:30 +0200
branchstable
changeset 1924 dc903af1a34e
parent 1802 d628defebc17
child 1977 606923dff11b
permissions -rw-r--r--
bump

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()