def main(): optparser = OptionParser() optparser.add_option("-c", "--configfile", dest="config", default="", help="Override the path to the config file to load.") opts, args = optparser.parse_args(sys.argv) if (opts.config != ""): try: config.from_pyfile(opts.config) except IOError: print "Could not find any configuration files. Exiting." sys.exit(0) create_app(config) if (len(args) < 2): print "Invalid arguments" sys.exit(0) if (args[1] == "paper") and len(args) > 2: #expect the next argument to be the operation p = PaperManager() p.parse_options(args[2:]) else: print "Invalid arguments."
def app(): """Create and configure a new app instance for each test.""" # create a temporary file to isolate the database for each test db_fd, db_path = tempfile.mkstemp() # create the app with common test config app = create_app({"TESTING": True, "DATABASE": db_path}) # create the database and load test data with app.app_context(): init_db() get_db().executescript(_data_sql) yield app # close and remove the temporary database os.close(db_fd) os.unlink(db_path)
import sys from partridge import create_app from partridge.config import config app = create_app( config )
from flask import Config from partridge.config import config optparser = OptionParser() optparser.add_option("-c", "--configfile", dest="config", default="", help="Override the path to the config file to load.") opts, args = optparser.parse_args(sys.argv) # config = Config({}) # if(opts.config != ""): # try: # config.from_pyfile(opts.config) # except IOError: # print ("Could not find any configuration files. Exiting.") # sys.exit(0) create_app(config) parser = PaperParser() if (len(args) < 2): print("Provide the name of a paper to import") sys.exit(0) print(parser.paperExists(args[1]))
def test_config(): """Test create_app without passing test config.""" assert not create_app().testing assert create_app({"TESTING": True}).testing