Пример #1
0
    def setUpClass(cls):
        """
        test setup class: instantiate app with modified config, initialize db
        """
        # load config given in APP_SETTINGS or use testConfig object
        config = os.environ.get('APP_SETTINGS')
        if config is None:
            config = __class__.testConfig

        cls.app = create_app(config)
        cls.test_client = cls.app.test_client()

        with cls.app.app_context():
            db.drop_all()
            db.create_all()
            db.session.commit()
    def setUpClass(cls):
        """
        test setup class: instantiate app with modified config, initialize db
        """
        # load config given in APP_SETTINGS or use testConfig object
        config = os.environ.get('APP_SETTINGS')
        if config is None:
            config = __class__.testConfig

        cls.app = create_app(config)
        cls.test_client = cls.app.test_client()

        with cls.app.app_context():
            db.drop_all()
            db.create_all()
            user_datastore.create_user(username='******',
                                       password=encrypt_password('plaintext'),
                                       api_key='adglhve')
            db.session.commit()
Пример #3
0
# from flask import Flask
# from flask_sqlalchemy import SQLAlchemy
import csv
import os
import sys
# import random
from base64 import b64encode

from flask_security.utils import encrypt_password
from homeautomation import create_app
from homeautomation.models import db, StockProductCategory, StockProduct,\
                                  user_datastore

app = create_app()

with app.app_context():
    app.logger.info('Recreating DB')
    db.drop_all()
    db.create_all()
    app.logger.info('Filling DB with test data')

    # Create the default roles
    app.logger.info('Filling DB with users')
    try:
        basic = user_datastore.find_or_create_role(name='User',
                                                   description="Basic user")
        admin = user_datastore.find_or_create_role(name='Admin',
                                                   description='API Administrator')

        # Create the default users
        user_datastore.create_user(username='******',
Пример #4
0
 def testDbInitialization(self):
     app = create_app(self.testConfig)
     with app.app_context():
         db.drop_all()
         db.create_all()
Пример #5
0
 def testConfigOverride(self):
     app = create_app(self.testConfig)
     self.assertEqual(self.testConfig.XXX, app.config['XXX'])
Пример #6
0
 def testApplicationFactory(self):
     app = create_app()
     self.assertIsNotNone(app)