def client(): """Use the client fixture to test requests to the application.""" ruddock.init("test") # Specify a server name (needed for url building in the test client). app.config["SERVER_NAME"] = "127.0.0.1" # Establish application context before running tests. ctx = app.app_context() ctx.push() return app.test_client()
def client(): """Use the client fixture to test requests to the application.""" ruddock.init("test") # Specify a server name (needed for url building in the test client). app.config["SERVER_NAME"] = "127.0.0.1" # Establish application context before running tests. ctx = app.app_context() ctx.push() # Create database engine object. engine = sqlalchemy.create_engine(app.config["DB_URI"], convert_unicode=True) # Connect to the database and publish it in flask.g flask.g.db = engine.connect() yield app.test_client() flask.g.db.close()
"""Runs a test server. Example usage: python run_server.py --env test --port 9001 """ import argparse import ruddock from ruddock import app parser = argparse.ArgumentParser( description="Run a local instance of the test server.") parser.add_argument( "--env", default="dev", help="Environment to run application in. Can be 'prod', 'dev', or 'test'. " + "Default is 'dev'.") parser.add_argument("--port", type=int, default=5000, help="Port to attach application to. Default is 5000.") if __name__ == "__main__": args = parser.parse_args() ruddock.init(args.env) app.run(port=args.port)
"""Runs a test server. Example usage: python run_server.py --env test --port 9001 """ import argparse import ruddock from ruddock import app parser = argparse.ArgumentParser( description="Run a local instance of the test server.") parser.add_argument("--env", default="dev", help="Environment to run application in. Can be 'prod', 'dev', or 'test'. " + "Default is 'dev'.") parser.add_argument("--port", type=int, default=5000, help="Port to attach application to. Default is 5000.") if __name__ == "__main__": args = parser.parse_args() ruddock.init(args.env) app.run(port=args.port)