2021-11-23 13:53:08 +01:00
|
|
|
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():
|
2021-12-03 09:41:00 +01:00
|
|
|
result = cli_runner.invoke(cli, ['config'])
|
|
|
|
print(result.stdout)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
2021-11-23 13:53:08 +01:00
|
|
|
result = cli_runner.invoke(cli, ['run'])
|
2021-12-03 09:41:00 +01:00
|
|
|
try:
|
2021-12-03 17:25:57 +01:00
|
|
|
assert result.exit_code == 0
|
2021-12-03 09:41:00 +01:00
|
|
|
except AssertionError as exc:
|
|
|
|
print(result.stdout)
|
|
|
|
raise exc
|
2021-11-23 13:53:08 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
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()
|
|
|
|
"""
|