Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
	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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
def client(app):
    with app.test_client() as client:
        _db.app = app
        _db.create_all()
        yield client
        _db.session.rollback()
        _db.drop_all()
Ejemplo n.º 5
0
def createdb():
    """
    Creates a database with all of the tables defined in
    the models file.
    """

    db.create_all()
    db.session.commit()
Ejemplo n.º 6
0
def db(app):
    _db.app = app
    with app.app_context():
        _db.create_all()

    yield _db

    _db.drop_all()
Ejemplo n.º 7
0
def db(app):
    """A database for the tests."""
    _db.app = app
    with app.app_context():
        _db.create_all()

    yield _db

    _db.drop_all()
Ejemplo n.º 8
0
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()
Ejemplo n.º 9
0
def db(app):
    _db.app = app

    with app.app_context():
        _db.create_all()

    yield _db

    _db.session.close()
    _db.drop_all()
Ejemplo n.º 10
0
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()
Ejemplo n.º 11
0
    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
Ejemplo n.º 13
0
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")
Ejemplo n.º 14
0
 def setup(self):
     db.drop_all()
     db.create_all()
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Ejemplo n.º 17
0
 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()
Ejemplo n.º 19
0
def create_db():
	db.create_all()
Ejemplo n.º 20
0
def db(app):
    _db.app = app
    with app.app_context():
        _db.create_all()
    yield _db
    _db.drop_all()
Ejemplo n.º 21
0
 def setUp(self):
     db.create_all()
Ejemplo n.º 22
0
def create_tables():
    db.create_all()
Ejemplo n.º 23
0
def syncdb():
    """Init/reset database."""
    db.drop_all()
    db.create_all()
Ejemplo n.º 24
0
def create_db():
    """Creates database"""
    db.create_all()
Ejemplo n.º 25
0
def initialize_db():
    app = create_app()
    with app.app_context():
        db.create_all(app=app)
Ejemplo n.º 26
0
def createdb():
    """ Creates a database with all of the tables defined in
        your SQLAlchemy models
    """

    db.create_all()
Ejemplo n.º 27
0
#!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)
    )
Ejemplo n.º 28
0
def create_all():
    """Create all db tables"""
    db.create_all()
Ejemplo n.º 29
0
#!/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))
Ejemplo n.º 30
0
def initdb():
    """Initializes an empty application database"""
    db.create_all()
Ejemplo n.º 31
0
def createdb():
    """ Creates a database with all of the tables defined in
        your SQLAlchemy models
    """

    db.create_all()
Ejemplo n.º 32
0
From Covid_Crimes_NYC.app import db
db.create_all()
Ejemplo n.º 33
0
def createdb():
    """
    Creates all database tables
    """
    db.create_all()
Ejemplo n.º 34
0
def createdb():
    '''Create a database from the tables defined in models.py.'''
    db.create_all()
Ejemplo n.º 35
0
def syncdb():
    if prompt_bool('Are you sure, this will delete your database'):
        db.drop_all()
        db.create_all()
    else:
        pass
Ejemplo n.º 36
0
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)
Ejemplo n.º 37
0
 def test_create_all(self):
     db.create_all()
     assert_equal([], db.rows('select * from data'))
Ejemplo n.º 38
0
def initdb():
  db.create_all()
  print 'Initialized the database'
Ejemplo n.º 39
0
#!/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))