devtools/testlib.py
changeset 9460 a2a0bc984863
parent 9404 3e3e9b37e177
child 9471 367fe83d9f98
equal deleted inserted replaced
9459:d3016c08b4ae 9460:a2a0bc984863
   274         while self._open_access:
   274         while self._open_access:
   275             self._open_access.pop().close()
   275             self._open_access.pop().close()
   276 
   276 
   277     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
   277     @deprecated('[3.19] explicitly use RepoAccess object in test instead')
   278     def set_cnx(self, cnx):
   278     def set_cnx(self, cnx):
   279         """"""
   279         """ """
   280         # XXX we want to deprecate this
   280         # XXX we want to deprecate this
   281         assert getattr(cnx, '_session', None) is not None
   281         assert getattr(cnx, '_session', None) is not None
   282         if cnx is self._admin_clt_cnx:
   282         if cnx is self._admin_clt_cnx:
   283             self._pop_custom_cnx()
   283             self._pop_custom_cnx()
   284         else:
   284         else:
   369         db_handler.build_db_cache(self.test_db_id, self.pre_setup_database)
   369         db_handler.build_db_cache(self.test_db_id, self.pre_setup_database)
   370 
   370 
   371         db_handler.restore_database(self.test_db_id)
   371         db_handler.restore_database(self.test_db_id)
   372         self.repo = db_handler.get_repo(startup=True)
   372         self.repo = db_handler.get_repo(startup=True)
   373         # get an admin session (without actual login)
   373         # get an admin session (without actual login)
   374         sources = db_handler.config.sources()
   374         login = unicode(db_handler.config.default_admin_config['login'])
   375         login = unicode(sources['admin']['login'])
       
   376         self.admin_access = self.new_access(login)
   375         self.admin_access = self.new_access(login)
   377         self._admin_session = self.admin_access._session
   376         self._admin_session = self.admin_access._session
   378         self._admin_clt_cnx = repoapi.ClientConnection(self._admin_session)
   377         self._admin_clt_cnx = repoapi.ClientConnection(self._admin_session)
   379         self._cnxs.add(self._admin_clt_cnx)
   378         self._cnxs.add(self._admin_clt_cnx)
   380         self._admin_clt_cnx.__enter__()
   379         self._admin_clt_cnx.__enter__()
   458 
   457 
   459         You may only want to override here the configuraton logic.
   458         You may only want to override here the configuraton logic.
   460 
   459 
   461         Otherwise, consider to use a different :class:`ApptestConfiguration`
   460         Otherwise, consider to use a different :class:`ApptestConfiguration`
   462         defined in the `configcls` class attribute"""
   461         defined in the `configcls` class attribute"""
   463         source = config.sources()['system']
   462         source = config.system_source_config
   464         cls.admlogin = unicode(source['db-user'])
   463         cls.admlogin = unicode(source['db-user'])
   465         cls.admpassword = source['db-password']
   464         cls.admpassword = source['db-password']
   466         # uncomment the line below if you want rql queries to be logged
   465         # uncomment the line below if you want rql queries to be logged
   467         #config.global_set_option('query-log-file',
   466         #config.global_set_option('query-log-file',
   468         #                         '/tmp/test_rql_log.' + `os.getpid()`)
   467         #                         '/tmp/test_rql_log.' + `os.getpid()`)