server/test/unittest_session.py
changeset 8555 c747242d22a6
parent 8542 7e264ce34cd4
child 8561 77ea3eed9946
equal deleted inserted replaced
8551:6cf9e4da54a9 8555:c747242d22a6
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    61         self.assertEqual(session.cnxset, None)
    61         self.assertEqual(session.cnxset, None)
    62         self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
    62         self.assertEqual(session.hooks_mode, session.HOOKS_ALLOW_ALL)
    63         self.assertEqual(session.disabled_hook_categories, set())
    63         self.assertEqual(session.disabled_hook_categories, set())
    64         self.assertEqual(session.enabled_hook_categories, set())
    64         self.assertEqual(session.enabled_hook_categories, set())
    65 
    65 
    66     def test_build_descr1(self):
       
    67         rset = self.execute('(Any U,L WHERE U login L) UNION (Any G,N WHERE G name N, G is CWGroup)')
       
    68         orig_length = len(rset)
       
    69         rset.rows[0][0] = 9999999
       
    70         description = self.session.build_description(rset.syntax_tree(), None, rset.rows)
       
    71         self.assertEqual(len(description), orig_length - 1)
       
    72         self.assertEqual(len(rset.rows), orig_length - 1)
       
    73         self.assertFalse(rset.rows[0][0] == 9999999)
       
    74 
       
    75     def test_build_descr2(self):
       
    76         rset = self.execute('Any X,Y WITH X,Y BEING ((Any G,NULL WHERE G is CWGroup) UNION (Any U,G WHERE U in_group G))')
       
    77         for x, y in rset.description:
       
    78             if y is not None:
       
    79                 self.assertEqual(y, 'CWGroup')
       
    80 
       
    81     def test_build_descr3(self):
       
    82         rset = self.execute('(Any G,NULL WHERE G is CWGroup) UNION (Any U,G WHERE U in_group G)')
       
    83         for x, y in rset.description:
       
    84             if y is not None:
       
    85                 self.assertEqual(y, 'CWGroup')
       
    86 
       
    87 
    66 
    88 if __name__ == '__main__':
    67 if __name__ == '__main__':
    89     unittest_main()
    68     unittest_main()