[conf] production now defaults to true

This commit is contained in:
Maxime Alves LIRMM 2021-11-22 18:30:29 +01:00
parent 0173eb6d72
commit 1f20a336e2
2 changed files with 24 additions and 2 deletions

View File

@ -48,7 +48,7 @@ from .logging import logger
PROJECT_NAME = environ.get('HALFAPI_PROJECT_NAME') or os.path.basename(os.getcwd())
DOMAINSDICT = lambda: {}
DOMAINS = {}
PRODUCTION = False
PRODUCTION = True
LOGLEVEL = 'info'
HOST = '127.0.0.1'
PORT = '3000'
@ -133,7 +133,7 @@ except FileNotFoundError as exc:
logger.error('Missing secret file: %s', exc)
PRODUCTION = config.getboolean('project', 'production',
fallback=environ.get('HALFAPI_PROD', False))
fallback=environ.get('HALFAPI_PROD', True))
LOGLEVEL = config.get('project', 'loglevel',
fallback=environ.get('HALFAPI_LOGLEVEL', 'info')).lower()

22
tests/test_conf.py Normal file
View File

@ -0,0 +1,22 @@
from halfapi.halfapi import HalfAPI
def test_conf_production_default():
halfapi = HalfAPI({
'DOMAINS': {'test': True}
})
assert halfapi.PRODUCTION is True
def test_conf_production_true():
halfapi = HalfAPI({
'PRODUCTION': True,
'DOMAINS': {'test': True}
})
assert halfapi.PRODUCTION is True
def test_conf_production_false():
halfapi = HalfAPI({
'PRODUCTION': False,
'DOMAINS': {'test': True}
})
assert halfapi.PRODUCTION is False