-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# pylint: disable=protected-access | ||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=too-many-arguments | ||
# pylint: disable=unused-argument | ||
# pylint: disable=unused-variable | ||
|
||
import json | ||
from typing import Any | ||
|
||
import pytest | ||
import simcore_service_director.models | ||
from pydantic import BaseModel, ValidationError | ||
from pytest_simcore.pydantic_models import walk_model_examples_in_package | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model_cls, example_name, example_data", | ||
walk_model_examples_in_package(simcore_service_director.models), | ||
) | ||
def test_director_service_model_examples( | ||
model_cls: type[BaseModel], example_name: int, example_data: Any | ||
): | ||
try: | ||
assert model_cls.parse_obj(example_data) is not None | ||
except ValidationError as err: | ||
pytest.fail( | ||
f"\n{example_name}: {json.dumps(example_data, indent=1)}\nError: {err}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=unused-argument | ||
# pylint: disable=unused-variable | ||
# pylint: disable=too-many-arguments | ||
import os | ||
|
||
from pytest_simcore.helpers.typing_env import EnvVarsDict | ||
from simcore_service_director._meta import API_VERSION | ||
from simcore_service_director.cli import main | ||
from simcore_service_director.core.settings import ApplicationSettings | ||
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, app_environment: EnvVarsDict): | ||
result = cli_runner.invoke(main, ["settings", "--show-secrets", "--as-json"]) | ||
assert result.exit_code == os.EX_OK | ||
|
||
settings = ApplicationSettings.parse_raw(result.output) | ||
assert settings.dict() == ApplicationSettings.create_from_envs().dict() | ||
|
||
|
||
def test_run(cli_runner: CliRunner): | ||
result = cli_runner.invoke(main, ["run"]) | ||
assert result.exit_code == 0 | ||
assert "disabled" in result.stdout |