Skip to content

Commit

Permalink
new cli
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 31, 2024
1 parent 4d3ebfc commit 972d87f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
9 changes: 7 additions & 2 deletions services/catalog/src/simcore_service_catalog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
from settings_library.http_client_request import ClientRequestSettings
from settings_library.postgres import PostgresSettings
from settings_library.rabbit import RabbitSettings
from settings_library.utils_cli import create_settings_command, print_as_envfile
from settings_library.utils_cli import (
create_settings_command,
create_version_callback,
print_as_envfile,
)

from ._meta import PROJECT_NAME
from ._meta import PROJECT_NAME, __version__
from .core.settings import ApplicationSettings, DirectorSettings

_logger = logging.getLogger(__name__)
Expand All @@ -18,6 +22,7 @@
main.command()(
create_settings_command(settings_cls=ApplicationSettings, logger=_logger)
)
main.callback()(create_version_callback(__version__))


@main.command()
Expand Down
1 change: 1 addition & 0 deletions services/catalog/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from simcore_service_catalog.core.settings import ApplicationSettings

pytest_plugins = [
"pytest_simcore.cli_runner",
"pytest_simcore.docker_compose",
"pytest_simcore.docker_registry",
"pytest_simcore.docker_swarm",
Expand Down
30 changes: 30 additions & 0 deletions services/catalog/tests/unit/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# pylint:disable=unused-variable
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

import os

from simcore_service_catalog._meta import API_VERSION
from simcore_service_catalog.cli import main
from typer.testing import CliRunner


def test_cli_help_and_version(cli_runner: CliRunner):
result = cli_runner.invoke(main, "--help")
assert result.exit_code == os.EX_OK, result.output

result = cli_runner.invoke(main, "--version")
assert result.exit_code == os.EX_OK, result.output
assert result.stdout.strip() == API_VERSION


def test_settings(cli_runner: CliRunner):
result = cli_runner.invoke(main, ["settings"])
assert result.exit_code == 0
assert "APP_NAME=simcore-service-autoscaling" in result.stdout


def test_run(cli_runner: CliRunner):
result = cli_runner.invoke(main, ["run"])
assert result.exit_code == 0
assert "disabled" in result.stdout

0 comments on commit 972d87f

Please sign in to comment.