[conf][testfail] add SCHEMA dictionary to globals
This commit is contained in:
parent
4dae2f3676
commit
ac4aadc2df
@ -1,9 +1,8 @@
|
||||
from .halfapi import HalfAPI
|
||||
from .conf import PRODUCTION, SECRET, DOMAINS, CONFIG
|
||||
from .conf import CONFIG, SCHEMA
|
||||
from .logging import logger
|
||||
|
||||
application = HalfAPI({
|
||||
'PRODUCTION': PRODUCTION,
|
||||
'SECRET': SECRET,
|
||||
'DOMAINS': DOMAINS,
|
||||
'CONFIG': CONFIG,
|
||||
}).application
|
||||
logger.info('CONFIG: %s', CONFIG)
|
||||
logger.info('SCHEMA: %s', SCHEMA)
|
||||
|
||||
application = HalfAPI(CONFIG, SCHEMA or None).application
|
||||
|
@ -9,8 +9,8 @@ import uvicorn
|
||||
|
||||
from .cli import cli
|
||||
from .domain import list_api_routes
|
||||
from ..conf import (PROJECT_NAME, HOST, PORT,
|
||||
PRODUCTION, LOGLEVEL, DOMAINSDICT)
|
||||
from ..conf import (PROJECT_NAME, HOST, PORT, SCHEMA,
|
||||
PRODUCTION, LOGLEVEL, DOMAINSDICT, CONFIG)
|
||||
from ..logging import logger
|
||||
|
||||
@click.option('--host', default=HOST)
|
||||
|
@ -53,6 +53,7 @@ HOST = '127.0.0.1'
|
||||
PORT = '3000'
|
||||
SECRET = ''
|
||||
CONF_FILE = os.environ.get('HALFAPI_CONF_FILE', '.halfapi/config')
|
||||
SCHEMA = {}
|
||||
|
||||
config = ConfigParser(allow_no_value=True)
|
||||
|
||||
|
@ -2,21 +2,44 @@ from halfapi.halfapi import HalfAPI
|
||||
|
||||
def test_conf_production_default():
|
||||
halfapi = HalfAPI({
|
||||
'DOMAINS': {'test': True}
|
||||
'domains': {'test': True}
|
||||
})
|
||||
assert halfapi.PRODUCTION is True
|
||||
|
||||
def test_conf_production_true():
|
||||
halfapi = HalfAPI({
|
||||
'PRODUCTION': True,
|
||||
'DOMAINS': {'test': True}
|
||||
'production': True,
|
||||
'domains': {'test': True}
|
||||
})
|
||||
assert halfapi.PRODUCTION is True
|
||||
|
||||
def test_conf_production_false():
|
||||
halfapi = HalfAPI({
|
||||
'PRODUCTION': False,
|
||||
'DOMAINS': {'test': True}
|
||||
'production': False,
|
||||
'domains': {'test': True}
|
||||
})
|
||||
assert halfapi.PRODUCTION is False
|
||||
|
||||
def test_conf_variables():
|
||||
from halfapi.conf import (
|
||||
CONFIG,
|
||||
SCHEMA,
|
||||
SECRET,
|
||||
DOMAINSDICT,
|
||||
PROJECT_NAME,
|
||||
HOST,
|
||||
PORT,
|
||||
CONF_DIR
|
||||
)
|
||||
|
||||
assert isinstance(CONFIG, dict)
|
||||
assert isinstance(SCHEMA, dict)
|
||||
assert isinstance(SECRET, str)
|
||||
assert isinstance(DOMAINSDICT(), dict)
|
||||
assert isinstance(PROJECT_NAME, str)
|
||||
assert isinstance(HOST, str)
|
||||
assert isinstance(PORT, str)
|
||||
assert str(int(PORT)) == PORT
|
||||
PORT = 'abc'
|
||||
assert str(int(PORT)) == PORT
|
||||
assert isinstance(CONF_DIR, str)
|
||||
|
Loading…
Reference in New Issue
Block a user