def setUp(self): # HACK: We kept getting db.printing inexplicably set to True, so patch # it to be False here. _real_db_execute = web.db.DB._db_execute def _db_execute(self, cur, sql_query): self.printing = False return _real_db_execute(self, cur, sql_query) web.db.DB._db_execute = _db_execute # Set the dev flag in Config to False. Config.load() Config.data['dev'] = False # Set the debug flag to true, despite what is in the config file web.config.debug = False web.config.session_parameters['cookie_name'] = 'gam' # TODO: Clean up this initialization web.ctx.method = '' web.ctx.path = '' import StringIO web.ctx.env = {'wsgi.input': StringIO.StringIO(), 'REQUEST_METHOD': ''} # Set up the routes app = web.application(main.ROUTES, globals()) # Grab a database connection self.db = main.sessionDB() # Initialize the session holder (I don't know what that is yet) #main.SessionHolder.set(web.session.Session(app, web.session.DBStore(db, 'web_session'))) # Finally, create a test app self.app = TestApp(app.wsgifunc())
def test_load(self): """ Test `load` method and that a config has been loaded. """ Config.load() self.assertIsNotNone(Config.data) self.assertIsInstance(Config.data, dict)
def setUp(self): Config.load() # Use the test_db, so that you don't blow stuff away. db_config = Config.get('database') if 'test_db' in db_config and db_config['test_db']: db_config['db'] = db_config['test_db'] # Grab a database connection self.db = main.sessionDB() self.install_db_structure(self.db) self.load_db_fixtures(self.db, *self.fixtures) # HACK: We kept getting db.printing inexplicably set to True, so patch # it to be False here. _real_db_execute = web.db.DB._db_execute def _db_execute(self, cur, sql_query): self.printing = False return _real_db_execute(self, cur, sql_query) web.db.DB._db_execute = _db_execute super(DbFixturesMixin, self).setUp()