Esempio n. 1
0
def test_get_default_values_for_api() -> None:
    """Check if default values saved in unit test configuration is properly defined."""
    config = AppConfiguration()

    assert config.get('api', 'host') == 'localhost'
    assert config.getint('api', 'rest_port') == 51000
    assert config.getint('api', 'websocket_port') == 51001
    assert not config.getboolean('api', 'debug')
    assert config.get('api', 'secret_key') == 'SECRET_KEY'
    assert config.get('db', 'database_uri') == 'sqlite:///:memory:'
Esempio n. 2
0
# Import all REST services
from medtagger.api.core.service import core_ns as core_rest_ns  # noqa
from medtagger.api.labels.service import labels_ns  # noqa
from medtagger.api.scans.service_rest import scans_ns as scans_rest_ns  # noqa
from medtagger.api.users.service import users_ns  # noqa
from medtagger.api.auth.service import auth_ns  # noqa

logger = logging.getLogger(__name__)

# Load configuration
logger.info('Loading configuration file...')
configuration = AppConfiguration()
host = configuration.get('api', 'host', fallback='localhost')
port = configuration.getint('api', 'rest_port', fallback=51000)
debug = configuration.getboolean('api', 'debug', fallback=True)

# Definition of application
app = Flask(__name__)
CORS(app)
app.secret_key = configuration.get('api', 'secret_key', fallback='')
app.register_blueprint(blueprint)

# Application config
app.config['RESTPLUS_MASK_SWAGGER'] = False
app.config['SWAGGER_UI_DOC_EXPANSION'] = 'list'
app.config['RESTPLUS_VALIDATE'] = True

try:
    # This will raise ModuleNotFoundError if app was not run inside uWSGI server
    from uwsgidecorators import postfork  # noqa