[run] add arguments for config
This commit is contained in:
parent
e7e1bfed1b
commit
ad6877a7e9
|
@ -11,15 +11,24 @@ from .cli import cli
|
|||
from .domain import list_api_routes
|
||||
from ..conf import (PROJECT_NAME, HOST, PORT,
|
||||
PRODUCTION, LOGLEVEL, DOMAINSDICT)
|
||||
from ..logging import logger
|
||||
|
||||
@click.option('--host', default=None)
|
||||
@click.option('--port', default=None)
|
||||
@click.option('--host', default=HOST)
|
||||
@click.option('--port', default=PORT)
|
||||
@click.option('--reload', default=False)
|
||||
@click.option('--secret', default=False)
|
||||
@click.option('--production', default=True)
|
||||
@click.option('--loglevel', default=LOGLEVEL)
|
||||
@click.option('--prefix', default='')
|
||||
@click.argument('schema', type=click.File('r'), required=False)
|
||||
@cli.command()
|
||||
def run(host, port, reload):
|
||||
def run(host, port, reload, secret, production, loglevel, prefix, schema):
|
||||
"""
|
||||
The "halfapi run" command
|
||||
"""
|
||||
logger.debug('[run] host=%s port=%s reload=%s secret=%s production=%s loglevel=%s prefix=%s schema=%s',
|
||||
host, port, reload, secret, production, loglevel, prefix, schema
|
||||
)
|
||||
|
||||
if not host:
|
||||
host = HOST
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
from click.testing import CliRunner
|
||||
from halfapi.cli.cli import cli
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def test_run_noproject(cli_runner):
|
||||
with cli_runner.isolated_filesystem():
|
||||
result = cli_runner.invoke(cli, ['run'])
|
||||
assert result.exit_code == 1
|
||||
|
||||
"""
|
||||
def test_run_empty_project(cli_runner):
|
||||
with cli_runner.isolated_filesystem():
|
||||
os.mkdir('dummy_domain')
|
||||
result = cli_runner.invoke(cli, ['run', './dummy_domain'])
|
||||
assert result.exit_code == 1
|
||||
|
||||
def test_run_dummy_project(project_runner):
|
||||
with patch('uvicorn.run', autospec=True) as runMock:
|
||||
result = project_runner.invoke(cli, ['run'])
|
||||
runMock.assert_called_once()
|
||||
"""
|
Loading…
Reference in New Issue