예제 #1
0
def createdb():
    """Create a database and init the administrator account."""
    from Qingblog.models import db
    db.create_all()

    from Qingblog.models import User 
    admin = User(id=1, name='harvey', password='******',
    email='*****@*****.**', role='admin')
    db.session.add(admin)
    db.session.commit()
예제 #2
0
    def setUp(self):
        """Pre-test activities."""
        config = {'TESTING': True}
        config['CSRF_ENABLED'] = False
        config['SECRET_KEY'] = 'secret-key-for-Qingblog-test'
        config['SQLALCHEMY_POOL_SIZE'] = 5

        # Set up a temp-database each test case.
        self.db_fd, self.db_file = tempfile.mkstemp()
        config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % self.db_file

        app = create_app(config)
        self.app = app
        self.client = app.test_client()

        # Init the database
        db.create_all()