def client(app): db.create_all() link1 = Link(id='example1', url='http://example1.com') link2 = Link(id='example2', url='http://example2.com') db.session.add_all([link1, link2]) db.session.commit() yield app.test_client() db.session.remove() db.drop_all()
def recreate_db(): db.drop_all() db.create_all()
def run(self): from url_shortener import db # db.drop_all() db.create_all() db.session.commit()
def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client(use_cookies=False)
def deploy(): from flask_migrate import upgrade upgrade() db.create_all()
def init_db_command(): """Create database tables.""" db.create_all()
def setUp(self): self.db_fd, self.db_fn = tempfile.mkstemp() app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + self.db_fn app.config['TESTING'] = True self.app = app.test_client() db.create_all()