devtools/testlib.py
changeset 9790 0872ac2a1db0
parent 9757 6eb7f361fba0
child 9836 71045bb09136
equal deleted inserted replaced
9789:4903a959604a 9790:0872ac2a1db0
   411 
   411 
   412     #XXX this doesn't need to a be classmethod anymore
   412     #XXX this doesn't need to a be classmethod anymore
   413     def _init_repo(self):
   413     def _init_repo(self):
   414         """init the repository and connection to it.
   414         """init the repository and connection to it.
   415         """
   415         """
   416         # setup configuration for test
       
   417         self.init_config(self.config)
       
   418         # get or restore and working db.
   416         # get or restore and working db.
   419         db_handler = devtools.get_test_db_handler(self.config)
   417         db_handler = devtools.get_test_db_handler(self.config, self.init_config)
   420         db_handler.build_db_cache(self.test_db_id, self.pre_setup_database)
   418         db_handler.build_db_cache(self.test_db_id, self.pre_setup_database)
   421 
       
   422         db_handler.restore_database(self.test_db_id)
   419         db_handler.restore_database(self.test_db_id)
   423         self.repo = db_handler.get_repo(startup=True)
   420         self.repo = db_handler.get_repo(startup=True)
   424         # get an admin session (without actual login)
   421         # get an admin session (without actual login)
   425         login = unicode(db_handler.config.default_admin_config['login'])
   422         login = unicode(db_handler.config.default_admin_config['login'])
   426         self.admin_access = self.new_access(login)
   423         self.admin_access = self.new_access(login)
   499             home = abspath(join(dirname(sys.modules[cls.__module__].__file__), cls.appid))
   496             home = abspath(join(dirname(sys.modules[cls.__module__].__file__), cls.appid))
   500             config = cls._config = cls.configcls(cls.appid, apphome=home)
   497             config = cls._config = cls.configcls(cls.appid, apphome=home)
   501             config.mode = 'test'
   498             config.mode = 'test'
   502             return config
   499             return config
   503 
   500 
   504     @classmethod
   501     @classmethod # XXX could be turned into a regular method
   505     def init_config(cls, config):
   502     def init_config(cls, config):
   506         """configuration initialization hooks.
   503         """configuration initialization hooks.
   507 
   504 
   508         You may only want to override here the configuraton logic.
   505         You may only want to override here the configuraton logic.
   509 
   506 
   510         Otherwise, consider to use a different :class:`ApptestConfiguration`
   507         Otherwise, consider to use a different :class:`ApptestConfiguration`
   511         defined in the `configcls` class attribute"""
   508         defined in the `configcls` class attribute.
       
   509 
       
   510         This method will be called by the database handler once the config has
       
   511         been properly bootstrapped.
       
   512         """
   512         source = config.system_source_config
   513         source = config.system_source_config
   513         cls.admlogin = unicode(source['db-user'])
   514         cls.admlogin = unicode(source['db-user'])
   514         cls.admpassword = source['db-password']
   515         cls.admpassword = source['db-password']
   515         # uncomment the line below if you want rql queries to be logged
   516         # uncomment the line below if you want rql queries to be logged
   516         #config.global_set_option('query-log-file',
   517         #config.global_set_option('query-log-file',