Esempio n. 1
0
    def setUp(self):

        self.app = app
        self.client = self.app.test_client()
        DEBUG = True
        TESTING =  True
        WTF_CSRF_ENABLED = False
        SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
        db.create_all()
Esempio n. 2
0
def fake():
    db.create_all()
    books = [
        {
            'title': 'My Neighbor Totoro',
            'year': '1988'
        },
        {
            'title': 'Dead Poets Society',
            'year': '1989'
        },
        {
            'title': 'A Perfect World',
            'year': '1993'
        },
        {
            'title': 'Leon',
            'year': '1994'
        },
        {
            'title': 'Mahjong',
            'year': '1996'
        },
        {
            'title': 'Swallowtail Butterfly',
            'year': '1996'
        },
        {
            'title': 'King of Comedy',
            'year': '1999'
        },
        {
            'title': 'Devils on the Doorstep',
            'year': '1999'
        },
        {
            'title': 'WALL-E',
            'year': '2008'
        },
        {
            'title': 'The Pork of Music',
            'year': '2012'
        },
    ]
    all_books = [
        Book(title=book['title'], year=book['year']) for book in books
    ]
    db.session.add_all(all_books)
    try:
        db.session.commit()
        click.echo('Success.')
    except:
        db.session.rollback()
    click.echo('Done.')
Esempio n. 3
0
def admin(username, password):
    db.create_all()
    try:
        user = User.query.filter_by(username=username).first()
    except:
        user = None
    if user is not None:
        click.echo('Updating user...')
        user.username = username
        user.set_password(password)
    else:
        click.echo('Creating user...')
        user = User(username=username, name="admin")
        user.set_password(password)
        db.session.add(user)
    try:
        db.session.commit()
        click.echo('Success Done.')
    except:
        db.session.rollback()
        click.echo('Worong Error.')
Esempio n. 4
0
 def setUp(self):
     DEBUG = True
     TESTING =  True
     WTF_CSRF_ENABLED = False
     SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
     db.create_all()
Esempio n. 5
0
from book import db
# noinspection PyUnresolvedReferences
from book.model import *

db.create_all()