def setUpClass(cls): """ Set up the test client :return: """ cls.client = app.test_client(use_cookies=True) cls.headers = {'content-type': 'application/json'} metadata.create_all(bind=test_engine)
def setUp(self): TestCaseWithAppContext.setUp(self) self.database_url = 'sqlite://' self.database_engine = create_engine(self.database_url) conf.DATABASE_URL = self.database_url conf.DATABASE_ENGINE = self.database_engine metadata.create_all(bind=conf.DATABASE_ENGINE)
if config_object.LOGFILE is not None: logging.basicConfig(filename=config_object.LOGFILE) set_logfile() @db_session() def create_root_user(session): """ If no root user is found in the DB, it makes a root user with the credentials given in the config :param ContextManagedSession session: The session to be used for making the root user """ user = session.query(Administrator).filter_by( username=conf.ROOT_USER).first() if not user: user = Administrator(conf.ROOT_USER, conf.ROOT_PASSWORD, conf.ROOT_EMAIL) session.add(user) if __name__ == "__main__": metadata.create_all(bind=conf.DATABASE_ENGINE) with app.test_request_context(): create_root_user() app.run(host=conf.IP_ADDRESS, port=conf.PORT, debug=conf.DEBUG)
def setUpClass(cls): auth.database_session = ContextManagedSession(bind=cls.engine) cls.username = '******' cls.password = '******' cls.email = '*****@*****.**' metadata.create_all(bind=cls.engine)