adding latest

This commit is contained in:
2021-11-04 00:01:38 +00:00
parent 544c90eeed
commit 83db380fec
3 changed files with 40 additions and 9 deletions

View File

@@ -42,6 +42,11 @@ Documentation:
Overwrite `__init__`, access them in pytest with `.value.$args`
Access them in a try,except with `raise $excpetion as $name; $name.$arg`
☐ Document capturing stdout
Use `capsys`
`assert capsys.readouterr().out`
A new line may be inserted if using `click.echo()`
☐ Document using datadir with a module rather than a shared one. Link to tembo as an example.
☐ Can prospector ignore tests dir? document this in the gist if so
☐ Redo the documentation on a CLI, reorganise and inocropoate all the new tembo layouts
@@ -68,6 +73,8 @@ Functionality:
☐ Update poetry
☐ Build docs
☐ Document using Duty
☐ Duty for auto insert version from `poetry version`.
Need to decide what file to place `__version__` in.
Logging:
☐ Make all internal tembo logs be debug

View File

@@ -149,13 +149,12 @@ def _new_get_config_scope(scope: str) -> dict:
def _new_show_example(example: bool, config_scope: dict) -> None:
if example:
tembo.cli.logger.info(
"Example for 'tembo new %s': %s",
config_scope["name"],
config_scope["example"]
if isinstance(config_scope["example"], str)
else "No example in config.yml",
if isinstance(config_scope["example"], str):
cli_message(
f'Example for {config_scope["name"]}: {config_scope["example"]}'
)
else:
cli_message("No example in config.yml")
raise SystemExit(0)

View File

@@ -5,7 +5,11 @@ import pytest
import tembo.exceptions
import tembo.cli
from tembo.cli.cli import _new_verify_name_exists, _new_get_config_scope
from tembo.cli.cli import (
_new_verify_name_exists,
_new_get_config_scope,
_new_show_example,
)
def test_cli_page_is_saved_success():
@@ -107,7 +111,6 @@ def test_new_get_config_scope_success(shared_datadir):
def test_new_get_config_scope_key_not_found(shared_datadir):
# arrange
# arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "missing_keys")
importlib.reload(tembo.cli)
@@ -122,3 +125,25 @@ def test_new_get_config_scope_key_not_found(shared_datadir):
assert (
str(mandatory_key_not_found.value) == "Key 'filename' not found in config.yml"
)
@pytest.mark.parametrize(
"path,message",
[
("success", "[TEMBO] Example for some_scope: tembo new some_scope 🐘\n"),
("optional_keys", "[TEMBO] No example in config.yml 🐘\n"),
],
)
def test_new_show_example(path, message, shared_datadir, capsys):
# arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / path)
importlib.reload(tembo.cli)
config_scope = _new_get_config_scope("some_scope")
# act
with pytest.raises(SystemExit) as system_exit:
_new_show_example(True, config_scope)
# assert
assert capsys.readouterr().out == message
assert system_exit.value.code == 0