diff --git a/manage.py b/manage.py index c6c34b4..1776896 100755 --- a/manage.py +++ b/manage.py @@ -1,71 +1,16 @@ #!/usr/bin/env python -from flask_script import Manager, Server, Option, prompt_bool -from flask_script.commands import Clean, ShowUrls -from flask_alembic import ManageMigrations, FlaskAlembicConfig -from alembic import command +from coaster.manage import init_manager -from hasmail import app -from hasmail import models +import hasmail +import hasmail.models as models +import hasmail.forms as forms +import hasmail.views as views from hasmail.models import db +from hasmail import app -manager = Manager(app) -database = Manager(usage="Perform database operations") - - -class InitedServer(Server): - def get_options(self): - return super(InitedServer, self).get_options() + ( - Option('-e', dest='env', default='dev', help="run server for this environment [default 'dev']"), - ) - - def handle(self, *args, **kwargs): - super(InitedServer, self).handle(*args, **kwargs) - - -class InitedMigrations(ManageMigrations): - def run(self, args): - super(InitedMigrations, self).run(args[1:]) - - -@manager.shell -def _make_context(): - return dict(app=app, db=db, models=models) - - -@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") -def drop(env): - "Drops database tables" - if prompt_bool("Are you sure you want to lose all your data?"): - db.drop_all() - - -@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") -def create(env): - "Creates database tables from sqlalchemy models" - db.create_all() - config = FlaskAlembicConfig("alembic.ini") - command.stamp(config, "head") - - -@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") -def setversion(env): - ''' - Manually set the alembic version of the - database to the provided value. - ''' - config = FlaskAlembicConfig("alembic.ini") - version = raw_input("Enter the alembic version to be set:") - command.stamp(config, version) - - -manager.add_command("db", database) -manager.add_command("runserver", InitedServer()) -manager.add_command("clean", Clean()) -manager.add_command("showurls", ShowUrls()) -manager.add_command("migrate", InitedMigrations()) - - -if __name__ == "__main__": +if __name__ == '__main__': + db.init_app(app) + manager = init_manager(app, db, hasmail=hasmail, models=models, forms=forms, views=views) manager.run() diff --git a/runtests.py b/runtests.py deleted file mode 100755 index af8b126..0000000 --- a/runtests.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: iso-8859-15 -*- -import nose - -nose.main() diff --git a/runtests.sh b/runtests.sh new file mode 100755 index 0000000..bc1ede1 --- /dev/null +++ b/runtests.sh @@ -0,0 +1,4 @@ +#!/bin/sh +export FLASK_ENV="TESTING" +coverage run `which nosetests` +coverage report