コード例 #1
0
    def setUp(self):
        """Initialize test variables
        """
        self.app = create_app(config_name="testing")
        self.client = self.app.test_client
        self.user_data = {
            'name': 'guy',
            'email': '*****@*****.**',
            'password': '******'
        }
        self.bucketlist = {
            'name': 'list1',
            'date': '01012018',
            'description': 'Some description'
        }
        self.bucketlist_item1 = {
            'name': 'bucketlist_item1',
            'description': 'Do stuff'
        }
        self.bucketlist_item2 = {
            'name': 'bucketlist_item2',
            'description': 'Do a little more stuff'
        }

        with self.app.app_context():
            db.session.close()
            db.drop_all()
            db.create_all()
コード例 #2
0
 def tearDown(self):
     """Tear down initialized variables
     """
     with self.app.app_context():
         # drop all tables
         db.session.remove()
         db.drop_all()
コード例 #3
0
ファイル: conftest.py プロジェクト: alysivji/flask-rq-example
def db(app):
    """Session-wide test database."""
    _db.app = app
    _db.create_all()
    yield _db

    _db.drop_all()
コード例 #4
0
def client():
    basedir = os.path.abspath(os.path.dirname(__file__))
    test_db_dir = os.path.join(basedir, "test.db")
    
    app = create_app("testing", "sqlite:///" + test_db_dir)
    test_client = app.test_client()
    with app.app_context():
        db.create_all()
        yield test_client
        db.drop_all()
コード例 #5
0
 def setUp(self):
     '''
     Define test variables and initialize app.
     '''
     self.app = create_app(config_name="testing")
     self.client = self.app.test_client
     with self.app.app_context():
         db.session.close()
         db.drop_all()
         db.create_all()
コード例 #6
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = POSTGRESQL_TEST_DB
     self.app = app.test_client()
     db.drop_all()
     db.get_engine(app).connect().execute(
         'DROP FUNCTION IF EXISTS post_search_vector_update();')
     db.create_all()
     self._populate_db_with_users()
コード例 #7
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()
コード例 #8
0
def session(application, docker_container):
    assert db.get_app().config['TESTING']
    db.session.rollback()
    db.drop_all()
    db.create_all()
    try:
        yield db.session
    except Exception:
        raise
    finally:
        # Roll back any trasactions that are in place before continuing
        db.session.rollback()
        db.drop_all()
コード例 #9
0
ファイル: test_auth.py プロジェクト: ro6ley/bucketlist
    def setUp(self):
        self.app = create_app(config_name="testing")
        # Set up the test client
        self.client = self.app.test_client
        self.user_data = json.dumps(
            dict({
                "username": "******",
                "email": "*****@*****.**",
                "password": "******"
            }))

        with self.app.app_context():
            # create all tables
            db.session.close()
            db.drop_all()
            db.create_all()
コード例 #10
0
ファイル: test_metron.py プロジェクト: MChrys/Metron
def init_database():
    #db = SQLAlchemy()
    # Create the database and the database table

    db.create_all()

    # Insert user data
    data = {'Name': 'Dog', 'Age': 5, 'Weight': 60, 'Human': False, 'Hat': None}

    character_schema = CharacterSchema()
    chara1 = Character(**data)

    db.session.add(chara1)

    # Commit the changes for the users
    db.session.commit()

    yield db
    db.session.close()
    db.drop_all()
コード例 #11
0
def initdb():
    db.drop_all(bind=None)
    db.create_all(bind=None)

    # add sample user
    user = User(username="******",
                email="*****@*****.**",
                active=True,
                password='******',
                confirmed=True)
    user_role = Role(name='user')
    db.session.add(user_role)
    admin_role = Role(name='admin')
    db.session.add(admin_role)
    user.roles.append(fetch_admin_role())
    user.roles.append(fetch_user_role())
    db.session.add(user)
    db.session.commit()
    config = BrowseConfig(name="config-test",
                          address='ws://172.0.0.3:8888',
                          user_id=user.id)
    db.session.add(config)
    db.session.commit()
コード例 #12
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
コード例 #13
0
ファイル: create_tables.py プロジェクト: deelaws/souvu
def refresh_db():
    with app.app_context():
        db.drop_all()
        db.create_all()
        create_sample_users()
        create_sample_vocabulary_memories(10)
コード例 #14
0
ファイル: db.py プロジェクト: kant-li/NewFlaskApp
def clear_mysql(app: fixture):
    """清理 mysql 数据"""
    yield
    with app.app_context():
        db.session.commit()
        db.drop_all()
コード例 #15
0
 def tearDown(self):
     with self.app_context():
         db.session.remove()
         db.drop_all()
コード例 #16
0
ファイル: test_items.py プロジェクト: ro6ley/bucketlist
 def tearDown(self):
     with self.app.app_context():
         # Drop all tables
         db.session.remove()
         db.drop_all()
コード例 #17
0
 def tearDown(self) -> None:
     """teardown all initialized variables."""
     with self.app.app_context():
         # drop all tables
         db.session.remove()
         db.drop_all()
コード例 #18
0
ファイル: __init__.py プロジェクト: TianhuiXu/Kanban-Board
 def tearDown(self):
     db.drop_all()
     self.context.pop()
コード例 #19
0
ファイル: manage.py プロジェクト: simtb/user-graphql-app
def drop():
    db.drop_all()
    return "Database has been dropped"
コード例 #20
0
    def setUp(self):
        app = self.create_app()

        db.drop_all()
        db.create_all()
        db.session.commit()
コード例 #21
0
ファイル: db_create.py プロジェクト: andrefaranha/flask-blog
    erat volutpat. In in eros diam.</p>

    <p>Donec sollicitudin magna non nibh viverra, non finibus magna posuere.
    Curabitur pretium ligula lacus, quis cursus arcu ultricies elementum. In
    vitae dui sed magna feugiat facilisis eget a lorem. Mauris turpis dui,
    placerat ac massa sed, mollis commodo lorem. In suscipit nunc in neque
    lobortis, nec aliquam nulla ultricies. Donec dictum mi non tortor finibus
    porta. Morbi gravida, tortor sed consectetur mattis, neque nulla varius
    nisl, posuere tristique enim nisi nec quam. Aliquam in ex nulla. Duis
    gravida ut lacus in laoreet. Fusce non risus aliquet, consequat elit ut,
    pharetra neque. Donec vitae mollis lacus. In fringilla viverra nisi.
    Pellentesque tristique lectus nibh, ac sagittis quam mollis ac. Fusce
    mollis aliquet sapien, et finibus sem vestibulum quis.</p>""",
]

db.drop_all()
db.get_engine(app).connect().execute(
    'DROP FUNCTION IF EXISTS post_search_vector_update();')
db.configure_mappers()
db.create_all()

users = [
    models.User('admin', '1', 'Administrator'),
    models.User('hal', '2', 'Hal Jordan'),
]

for user in users:
    db.session.add(user)
db.session.commit()

user_1 = models.User.query.filter(models.User.login == 'admin').first()
コード例 #22
0
ファイル: manage.py プロジェクト: Gitwangziwang/movie
def drop():  # 删除数据库
    db.drop_all()
    return '数据库删除完成'
コード例 #23
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
コード例 #24
0
def drop_db():
    db.drop_all()
コード例 #25
0
 def tearDown(self):
     print("Dropping all test tables")
     db.session.commit()
     db.drop_all()
コード例 #26
0
 def teardown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
コード例 #27
0
ファイル: layers.py プロジェクト: BartKrol/tvmanager
 def testTearDown(cls, test):
     """Tear down the database per test case"""
     db.session.remove()
     db.drop_all()
コード例 #28
0
ファイル: model.py プロジェクト: jprusik/steam-gauge
def littleBobby():
    db.drop_all()