コード例 #1
0
import os
import distutils.spawn
import types
import pathlib
import shutil

from survey_app import models
from survey_app.tests.fixtures import TMP_DIR

from baselayer.app.config import load_config
from baselayer.app.test_util import (driver, MyCustomWebDriver, reset_state,
                                     set_server_url)

print('Loading test configuration from _test_config.yaml')
basedir = pathlib.Path(os.path.dirname(__file__)) / '../..'
cfg = load_config([basedir / 'test_config.yaml'])
print('\n\n\n', cfg, '\n\n\n')
set_server_url(cfg['server']['url'])
print('Setting test database to:', cfg['database'])
print('initing models...')
models.init_db(**cfg['database'])
print('inited models')


@pytest.fixture(scope='session', autouse=True)
def delete_temporary_files(request):
    def teardown():
        shutil.rmtree(TMP_DIR, ignore_errors=True)

    request.addfinalizer(teardown)
コード例 #2
0
    FollowupRequest,
    Allocation,
    Invitation,
    SourceNotification,
    UserNotification,
)

import tdtax

TMP_DIR = mkdtemp()
env, cfg = load_env()

print("Loading test configuration from _test_config.yaml")
basedir = pathlib.Path(os.path.dirname(__file__))
cfg = load_config([(basedir / "../../test_config.yaml").absolute()])
set_server_url(f'http://localhost:{cfg["ports.app"]}')
print("Setting test database to:", cfg["database"])
init_db(**cfg["database"])


def is_already_deleted(instance, table):
    """
    Helper function to check if a given ORM instance has already been deleted previously,
    either by earlier teardown functions or by a test itself through the API.
    """
    # If the instance is marked detached, that means it was deleted earlier in the
    # current transaction.
    if instance in DBSession() and inspect(instance).detached:
        return True

    if instance not in DBSession():
コード例 #3
0
ファイル: conftest.py プロジェクト: acrellin/cesium_web
import pathlib
import shutil
from pytest_factoryboy import register, LazyFixture
from baselayer.app.config import load_config
from baselayer.app.test_util import (driver, MyCustomWebDriver, reset_state,
                                     set_server_url)
from cesium_app import models
from cesium_app.tests.fixtures import (TMP_DIR, ProjectFactory, DatasetFactory,
                                       FeaturesetFactory, ModelFactory,
                                       PredictionFactory)


print('Loading test configuration from test_config.yaml')
basedir = pathlib.Path(os.path.dirname(__file__))/'../..'
cfg = load_config([basedir/'test_config.yaml'])
set_server_url(f'http://*****:*****@pytest.fixture(scope='session', autouse=True)
def delete_temporary_files(request):
    def teardown():
        shutil.rmtree(TMP_DIR, ignore_errors=True)
    request.addfinalizer(teardown)


register(ProjectFactory)
register(DatasetFactory)
register(DatasetFactory, "unlabeled_dataset", name="unlabeled")
register(FeaturesetFactory)