server/test/unittest_session.py
changeset 8542 7e264ce34cd4
parent 7970 83075d897943
child 8554 6e5d8512b07d
equal deleted inserted replaced
8541:5b6bc27ece6e 8542:7e264ce34cd4
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 from __future__ import with_statement
    18 from __future__ import with_statement
    19 
    19 
    20 from logilab.common.testlib import TestCase, unittest_main, mock_object
       
    21 
       
    22 from cubicweb.devtools.testlib import CubicWebTC
    20 from cubicweb.devtools.testlib import CubicWebTC
    23 from cubicweb.server.session import _make_description, hooks_control
    21 from cubicweb.server.session import hooks_control
    24 
       
    25 class Variable:
       
    26     def __init__(self, name):
       
    27         self.name = name
       
    28         self.children = []
       
    29 
       
    30     def get_type(self, solution, args=None):
       
    31         return solution[self.name]
       
    32     def as_string(self):
       
    33         return self.name
       
    34 
       
    35 class Function:
       
    36     def __init__(self, name, varname):
       
    37         self.name = name
       
    38         self.children = [Variable(varname)]
       
    39     def get_type(self, solution, args=None):
       
    40         return 'Int'
       
    41 
       
    42 class MakeDescriptionTC(TestCase):
       
    43     def test_known_values(self):
       
    44         solution = {'A': 'Int', 'B': 'CWUser'}
       
    45         self.assertEqual(_make_description((Function('max', 'A'), Variable('B')), {}, solution),
       
    46                           ['Int','CWUser'])
       
    47 
    22 
    48 
    23 
    49 class InternalSessionTC(CubicWebTC):
    24 class InternalSessionTC(CubicWebTC):
    50     def test_dbapi_query(self):
    25     def test_dbapi_query(self):
    51         session = self.repo.internal_session()
    26         session = self.repo.internal_session()