equal
deleted
inserted
replaced
188 def pyro_enabled(self): |
188 def pyro_enabled(self): |
189 # but export PYRO_MULTITHREAD=0 or you get problems with sqlite and |
189 # but export PYRO_MULTITHREAD=0 or you get problems with sqlite and |
190 # threads |
190 # threads |
191 return True |
191 return True |
192 |
192 |
193 |
193 # XXX merge with BaseApptestConfiguration ? |
194 class ApptestConfiguration(BaseApptestConfiguration): |
194 class ApptestConfiguration(BaseApptestConfiguration): |
195 |
195 |
196 def __init__(self, appid, log_threshold=logging.CRITICAL, sourcefile=None): |
196 def __init__(self, appid, log_threshold=logging.CRITICAL, sourcefile=None): |
197 BaseApptestConfiguration.__init__(self, appid, log_threshold=log_threshold) |
197 BaseApptestConfiguration.__init__(self, appid, log_threshold=log_threshold) |
198 self.init_repository = sourcefile is None |
198 self.init_repository = sourcefile is None |
199 self.sourcefile = sourcefile |
199 self.sourcefile = sourcefile |
|
200 |
200 |
201 |
201 class RealDatabaseConfiguration(ApptestConfiguration): |
202 class RealDatabaseConfiguration(ApptestConfiguration): |
202 """configuration class for tests to run on a real database. |
203 """configuration class for tests to run on a real database. |
203 |
204 |
204 The intialization is done by specifying a source file path. |
205 The intialization is done by specifying a source file path. |
217 self.view('foaf', rset) |
218 self.view('foaf', rset) |
218 |
219 |
219 """ |
220 """ |
220 db_require_setup = False # skip init_db / reset_db steps |
221 db_require_setup = False # skip init_db / reset_db steps |
221 read_instance_schema = True # read schema from database |
222 read_instance_schema = True # read schema from database |
|
223 |
222 |
224 |
223 # test database handling ####################################################### |
225 # test database handling ####################################################### |
224 |
226 |
225 def init_test_database(config=None, configdir='data'): |
227 def init_test_database(config=None, configdir='data'): |
226 """init a test database for a specific driver""" |
228 """init a test database for a specific driver""" |
239 repo, cnx = in_memory_cnx(config, unicode(sources['admin']['login']), |
241 repo, cnx = in_memory_cnx(config, unicode(sources['admin']['login']), |
240 password=sources['admin']['password'] or 'xxx') |
242 password=sources['admin']['password'] or 'xxx') |
241 if driver == 'sqlite': |
243 if driver == 'sqlite': |
242 install_sqlite_patch(repo.querier) |
244 install_sqlite_patch(repo.querier) |
243 return repo, cnx |
245 return repo, cnx |
244 |
|
245 |
246 |
246 def reset_test_database(config): |
247 def reset_test_database(config): |
247 """init a test database for a specific driver""" |
248 """init a test database for a specific driver""" |
248 if not config.db_require_setup: |
249 if not config.db_require_setup: |
249 return |
250 return |
340 from cubicweb.server import init_repository |
341 from cubicweb.server import init_repository |
341 init_repository(config, interactive=False) |
342 init_repository(config, interactive=False) |
342 dbfile = config.sources()['system']['db-name'] |
343 dbfile = config.sources()['system']['db-name'] |
343 shutil.copy(dbfile, '%s-template' % dbfile) |
344 shutil.copy(dbfile, '%s-template' % dbfile) |
344 |
345 |
345 |
|
346 def install_sqlite_patch(querier): |
346 def install_sqlite_patch(querier): |
347 """This patch hotfixes the following sqlite bug : |
347 """This patch hotfixes the following sqlite bug : |
348 - http://www.sqlite.org/cvstrac/tktview?tn=1327,33 |
348 - http://www.sqlite.org/cvstrac/tktview?tn=1327,33 |
349 (some dates are returned as strings rather thant date objects) |
349 (some dates are returned as strings rather thant date objects) |
350 """ |
350 """ |