def reset_db(): """Reset database""" print "WARNING: This will reset the database and may cause data loss." response = raw_input("Are you sure you want to continue? (Yes/No) ") if not response == "Yes": print "Aborted." sys.exit() db.drop_all() db.create_all() admin = User( name=u'admin', email=u'*****@*****.**', password=u'123456', role_code=ADMIN, status_code=ACTIVE, user_detail=UserDetail( gender_code=MALE, age=25, url=u'http://example.com', location=u'Kampala', bio=u'')) db.session.add(admin) english = Language(name="English",iso639_1="en",iso639_2="eng",locale_code="en_UG") db.session.add(english) luganda = Language(name="Luganda",iso639_1="lg",iso639_2="lug",locale_code="lg_UG") db.session.add(luganda) db.session.commit() alembic_cfg = Config("alembic.ini") command.stamp(alembic_cfg, "head")
def client(request): rootio_app = create_app(config=TestConfig) with rootio_app.app_context(): # alternative pattern to app.app_context().push() # all commands indented under 'with' are run in the app context db.create_all() yield rootio_app.test_client() db.session.remove() db.drop_all()
def reset_db(noinput=False): """Reset database""" if not noinput: print "WARNING: This will reset the database and may cause data loss." response = raw_input("Are you sure you want to continue? (Yes/No) ") if not response == "Yes": print "Aborted." sys.exit() db.drop_all() db.create_all() admin = User(name=u'admin', email=u'*****@*****.**', password=u'123456', role_code=ADMIN, status_code=ACTIVE, user_detail=UserDetail(gender_code=MALE, age=25, url=u'http://example.com', location=u'Kampala', bio=u'')) db.session.add(admin) english = Language(name="English", iso639_1="en", iso639_2="eng", locale_code="en_UG") db.session.add(english) luganda = Language(name="Luganda", iso639_1="lg", iso639_2="lug", locale_code="lg_UG") db.session.add(luganda) db.session.commit() alembic_cfg = Config("alembic.ini") command.stamp(alembic_cfg, "head")
def setUp(self): """Reset all tables before testing.""" db.create_all() self.init_data()