def testapp(request): app = create_app('{{cookiecutter.app_name}}.settings.TestConfig') client = app.test_client() db.app = app db.create_all() if getattr(request.module, "create_user", True): admin = User(username="******", password="******") admin.insert() my_role = Role(name='admin') my_role.insert() admin.add_roles('admin') non_admin = User(username="******", password="******") non_admin.insert() safe_commit() def teardown(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return client
def setUp(self): unittest.TestCase.setUp(self) self.now = datetime(2012, 10, 15, 12, 30, 45) self.session = db.session self._next_steam_id = 0 self._next_twitch_id = 0 db.create_all()
def setUp(self): self.app = create_app(TestingConfig) self.app_context = self.app.app_context() self.app_context.push() self.request_context = self.app.test_request_context() self.request_context.push() db.create_all()
def client(app): with app.test_client() as client: _db.app = app _db.create_all() yield client _db.session.rollback() _db.drop_all()
def createdb(): """ Creates a database with all of the tables defined in the models file. """ db.create_all() db.session.commit()
def db(app): _db.app = app with app.app_context(): _db.create_all() yield _db _db.drop_all()
def db(app): """A database for the tests.""" _db.app = app with app.app_context(): _db.create_all() yield _db _db.drop_all()
def init(): db.drop_all() db.create_all() camera = Camera(focal_length=0.9, height=0.23, width=0.23) pc_1 = PerspectiveCenterPoint(x=100, y=0, z=4000) pc_2 = PerspectiveCenterPoint(x=900, y=0, z=3000) image_1 = Image(tag='image_1', camera=camera, perspective_center=pc_1, rx=0, ry=0, rz=0) image_2 = Image(tag='image_2', camera=camera, perspective_center=pc_2, rx=0, ry=0, rz=0) db.session.add(camera) db.session.commit()
def db(app): _db.app = app with app.app_context(): _db.create_all() yield _db _db.session.close() _db.drop_all()
def db(app): """A database for the tests.""" _db.app = app with app.app_context(): _db.create_all() yield _db # Explicitly close DB connection _db.session.close() _db.drop_all()
def __init__(self, config, section, root=None, engine=None, dmd=True): #a mock-friendly datetime self.dt = DateShift() if section not in config.sections(): raise ConfigException('There is not such job') self.logger = logging.getLogger(__name__) if engine is None: engine = setts.engine self.cf = getattr(config, section) self.section = section self.args['jobname'] = section check_file(self.cf.dar_bin, ConfigException) if root is not None: self.args['path'] = root else: self.args['path'] = self.cf.root for opt in self.cf.options(): self.args[opt] = getattr(self.cf, opt) create_all(engine) Sess = sessionmaker(bind=engine) self.sess = Sess(bind=engine) #init dardrive backup types for btype, ext in dardrive_types: setattr(self, btype, self.get_or_create(BackupType, name=btype)) for each_section in config.sections(): self.get_or_create(Job, name=each_section) self.sess.commit() self.Job = self.get_or_create(Job, name=section) self.dmd = os.path.expanduser('~/.dardrive/dmd/%s.dmd' % section) if not os.path.exists(self.dmd) and dmd: args = {'dar_manager': self.cf.dar_manager_bin, 'dmd_file': self.dmd} run = self.run_command('%(dar_manager)s -C %(dmd_file)s', args) if run[0].returncode > 0: raise BackupException
def testapp(request): app = create_app('{{cookiecutter.repo_name}}.settings.TestConfig', env='dev') client = app.test_client() db.app = app db.create_all() if getattr(request.module, "create_user", True): admin = User('admin', 'supersafepassword') db.session.add(admin) db.session.commit() def teardown(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return client
def init(): """Init application, create database tables and create a new user named admin with password admin """ from {{cookiecutter.app_name}}.extensions import db from {{cookiecutter.app_name}}.models import User click.echo("create database") db.create_all() click.echo("done") click.echo("create user") user = User( username='******', email='*****@*****.**', password='******', active=True ) db.session.add(user) db.session.commit() click.echo("created user admin")
def setup(self): db.drop_all() db.create_all()
def test_db_init_seed(app): """Try initializing and seeding development database.""" drop_all_tables(app=app) db.create_all(app=app) seed_db() drop_all_tables(app=app)
def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
def create_app(self): app = create_app(TestConfig) with app.app_context(): db.create_all() return app
def init_libs(self): db.init_app(self.application) with self.application.test_request_context(): db.create_all()
def create_db(): db.create_all()
def setUp(self): db.create_all()
def create_tables(): db.create_all()
def syncdb(): """Init/reset database.""" db.drop_all() db.create_all()
def create_db(): """Creates database""" db.create_all()
def initialize_db(): app = create_app() with app.app_context(): db.create_all(app=app)
def createdb(): """ Creates a database with all of the tables defined in your SQLAlchemy models """ db.create_all()
#!flask/bin/python from migrate.versioning import api # from config import SQLALCHEMY_DATABASE_URI # from config import SQLALCHEMY_MIGRATE_REPO from renbroc import app import db import os.path db.create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, "database repository") api.version_control(app.config["SQLALCHEMY_DATABASE_URI"], SQLALCHEMY_MIGRATE_REPO) else: api.version_control( app.config["SQLALCHEMY_DATABASE_URI"], SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO) )
def create_all(): """Create all db tables""" db.create_all()
#!/usr/bin/env python from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from db import create_all import os.path create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) else: api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
def initdb(): """Initializes an empty application database""" db.create_all()
From Covid_Crimes_NYC.app import db db.create_all()
def createdb(): """ Creates all database tables """ db.create_all()
def createdb(): '''Create a database from the tables defined in models.py.''' db.create_all()
def syncdb(): if prompt_bool('Are you sure, this will delete your database'): db.drop_all() db.create_all() else: pass
def create(default_data=True, sample_data=False): """Creates database tables from sqlalchemy models""" db.create_all() if default_data or sample_data: populate(default_data, sample_data)
def test_create_all(self): db.create_all() assert_equal([], db.rows('select * from data'))
def initdb(): db.create_all() print 'Initialized the database'