Esempio n. 1
0
    def setUp(self):
        logging.basicConfig(
            level='ERROR',
            format='[%(asctime)s] (%(levelname)s) %(module)s.%(funcName)s:%(lineno)d %(message)s',
            datefmt='%Y-%m-%d %I:%M:%S %p'
        )

        self.start_redis()
        self.config = {
            'sql_connection': 'dsn=SQLServer;uid=fakeuser;pwd=fakepassword;database=LIGHTNING_TEST;driver={SQL Server Native Client 10.0}',
            'environment': 'local',
            'redis_host': 'localhost',
            'redis_port': self.redis_port,
        }

        @defer.inlineCallbacks
        def on_build(app):
            self.app = app
            yield self.reset_db(app.db)
            if self.use_networking:
                self.listeners = [
                    reactor.listenTCP(0, self.app.site),
                ]


        # XXX - something goes wrong in the teardown process related to the redis connection pool
        # that we  can't figure out.  Fortunately, none of our tests actually need
        # to make use of that connection pool, so we added this do_connect_redis parameter to skip the
        # creation of the redis connection pool when running tests.
        return Lightning.build(self.config, do_connect_redis=False).addCallback(on_build)