test/unittest_repoapi.py
changeset 9061 e86fdab3d296
parent 9052 4cba5f2cd57b
child 9062 fa5bc8aef7ed
equal deleted inserted replaced
9060:8c0016d7a091 9061:e86fdab3d296
    19 
    19 
    20 
    20 
    21 from cubicweb.devtools.testlib import CubicWebTC
    21 from cubicweb.devtools.testlib import CubicWebTC
    22 
    22 
    23 from cubicweb import ProgrammingError
    23 from cubicweb import ProgrammingError
    24 from cubicweb.repoapi import ClientConnection
    24 from cubicweb.repoapi import ClientConnection, connect
    25 
    25 
    26 
    26 
    27 class REPOAPITC(CubicWebTC):
    27 class REPOAPITC(CubicWebTC):
    28 
    28 
    29     def test_clt_cnx_basic_usage(self):
    29     def test_clt_cnx_basic_usage(self):
    64             cltcnx.execute('Any X WHERE X is CWUser')
    64             cltcnx.execute('Any X WHERE X is CWUser')
    65         # connection closed
    65         # connection closed
    66         with self.assertRaises(ProgrammingError):
    66         with self.assertRaises(ProgrammingError):
    67             cltcnx.execute('Any X WHERE X is CWUser')
    67             cltcnx.execute('Any X WHERE X is CWUser')
    68 
    68 
       
    69     def test_connect(self):
       
    70         """check that repoapi.connect works and return a usable connection"""
       
    71         clt_cnx = connect(self.repo, login='admin', password='gingkow')
       
    72         self.assertEqual('admin', clt_cnx.user.login)
       
    73         with clt_cnx:
       
    74             rset = clt_cnx.execute('Any X WHERE X is CWUser')
       
    75             self.assertTrue(rset)
    69 
    76 
    70 
    77 
       
    78 
       
    79