示例#1
0
文件: utils.py 项目: fmin2958/manwe
    def setup(self):
        self._temp_dir = tempfile.mkdtemp(prefix='manwe-tests-')
        self._varda = varda.create_app({
            'TESTING': True,
            'DATA_DIR': self._temp_dir,
            'SECONDARY_DATA_DIR': os.path.dirname(os.path.realpath(__file__)),
            'GENOME': None,
            'REFERENCE_MISMATCH_ABORT': False,
            'SQLALCHEMY_DATABASE_URI': 'sqlite://',
            'BROKER_URL': 'memory://',
            'CELERY_RESULT_BACKEND': 'cache',
            'CELERY_CACHE_BACKEND': 'memory'
        })
        self._varda_app_context = self._varda.app_context()
        self._varda_app_context.push()

        varda.db.create_all()

        self._varda_client = self._varda.test_client()

        httpretty.enable()

        for method in (httpretty.GET, httpretty.POST, httpretty.PATCH,
                       httpretty.DELETE, httpretty.HEAD):
            httpretty.register_uri(method, re.compile('%s.*' % self.api_root),
                                   body=self._proxy_request)

        self.create_fixtures()
示例#2
0
文件: test_api.py 项目: varda/varda
 def setup(self):
     """
     Run once before every test. Setup the test database.
     """
     self.app = create_app(TEST_SETTINGS)
     self.client = self.app.test_client()
     with self.app.test_request_context():
         db.create_all()
         admin = User("Test Admin", "admin", "test", roles=["admin"])
         db.session.add(admin)
         trader = User("Test Trader", "trader", "test", roles=["importer", "trader"])
         db.session.add(trader)
         user = User("Test User", "user", "test", roles=[])
         db.session.add(user)
         db.session.commit()
示例#3
0
文件: test_tasks.py 项目: varda/varda
 def create_app(self):
     return create_app(TEST_SETTINGS)
示例#4
0
文件: env.py 项目: varda/varda
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
#target_metadata = None
import os
import site
site.addsitedir(os.getcwd())
from varda import create_app, db
app = create_app()
target_metadata = db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.

def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.