Skip to content

Commit 68f683c

Browse files
author
Andrei Neagu
committed
fixed cli tests
1 parent 143d04a commit 68f683c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

services/dask-sidecar/src/simcore_service_dask_sidecar/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22

33
import typer
4+
from models_library.utils.json_serialization import json_dumps
45
from settings_library.utils_cli import create_settings_command, create_version_callback
56

67
from ._meta import PROJECT_NAME, __version__
@@ -15,4 +16,8 @@
1516
# COMMANDS
1617
#
1718
main.callback()(create_version_callback(__version__))
18-
main.command()(create_settings_command(settings_cls=Settings, logger=_logger))
19+
main.command()(
20+
create_settings_command(
21+
settings_cls=Settings, logger=_logger, json_serializer=json_dumps
22+
)
23+
)

services/dask-sidecar/tests/unit/test_cli.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,35 @@
66

77

88
import os
9+
import traceback
910

11+
from click.testing import Result
1012
from pytest_simcore.helpers.typing_env import EnvVarsDict
1113
from simcore_service_dask_sidecar._meta import API_VERSION
1214
from simcore_service_dask_sidecar.cli import main
1315
from simcore_service_dask_sidecar.settings import Settings
1416
from typer.testing import CliRunner
1517

1618

19+
def _format_cli_error(result: Result) -> str:
20+
assert result.exception
21+
tb_message = "\n".join(traceback.format_tb(result.exception.__traceback__))
22+
return tb_message
23+
24+
1725
def test_cli_help_and_version(cli_runner: CliRunner):
1826
# invitations-maker --help
1927
result = cli_runner.invoke(main, "--help")
20-
assert result.exit_code == os.EX_OK, result.output
28+
assert result.exit_code == os.EX_OK, _format_cli_error(result)
2129

2230
result = cli_runner.invoke(main, "--version")
23-
assert result.exit_code == os.EX_OK, result.output
31+
assert result.exit_code == os.EX_OK, _format_cli_error(result)
2432
assert result.stdout.strip() == API_VERSION
2533

2634

2735
def test_list_settings(cli_runner: CliRunner, app_environment: EnvVarsDict):
2836
result = cli_runner.invoke(main, ["settings", "--show-secrets", "--as-json"])
29-
assert result.exit_code == os.EX_OK, result.output
37+
assert result.exit_code == os.EX_OK, _format_cli_error(result)
3038

3139
print(result.output)
3240
settings = Settings.parse_raw(result.output)

0 commit comments

Comments
 (0)