adding latest

This commit is contained in:
2021-11-03 20:48:40 +00:00
parent bfb4d7fd8f
commit 544c90eeed
5 changed files with 58 additions and 14 deletions

View File

@@ -46,6 +46,13 @@ Documentation:
☐ Can prospector ignore tests dir? document this in the gist if so ☐ 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 ☐ Redo the documentation on a CLI, reorganise and inocropoate all the new tembo layouts
Testing:
☐ Document importing in inidivudal tests using `importlib.reload`
Globally import the module
Use `importlib.reload(module)` in each test instead of explicitly importing the module.
This is because the import is cached.
<https://stackoverflow.com/questions/32234156/how-to-unimport-a-python-module-which-is-already-imported>
Functionality: Functionality:
☐ Replace loggers with `click.echo` for command outputs. Keep logging messages for actual logging messages? ☐ Replace loggers with `click.echo` for command outputs. Keep logging messages for actual logging messages?
Define a format: [TEMBO:$datetime] $message 🐘 - document this in general python for CLI Define a format: [TEMBO:$datetime] $message 🐘 - document this in general python for CLI

View File

@@ -141,9 +141,6 @@ def _new_get_config_scope(scope: str) -> dict:
if key_error.args[0] in optional_keys: if key_error.args[0] in optional_keys:
config_scope.update({key_error.args[0]: None}) config_scope.update({key_error.args[0]: None})
continue continue
tembo.cli.logger.critical(
"Key %s not found in config. yml - exiting", key_error
)
raise exceptions.MandatoryKeyNotFound( raise exceptions.MandatoryKeyNotFound(
f"Key {key_error} not found in config.yml" f"Key {key_error} not found in config.yml"
) )

View File

@@ -0,0 +1,5 @@
tembo:
scopes:
- name: some_scope
path: "some_scope"
extension: md

View File

@@ -0,0 +1,6 @@
tembo:
scopes:
- name: some_scope
path: "some_scope"
filename: "{name}"
extension: md

View File

@@ -1,8 +1,11 @@
import importlib
import os import os
import pytest import pytest
import tembo.exceptions import tembo.exceptions
import tembo.cli
from tembo.cli.cli import _new_verify_name_exists, _new_get_config_scope
def test_cli_page_is_saved_success(): def test_cli_page_is_saved_success():
@@ -12,8 +15,7 @@ def test_cli_page_is_saved_success():
def test_new_verify_name_exists_success(shared_datadir): def test_new_verify_name_exists_success(shared_datadir):
# arrange # arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success") os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success")
import tembo.cli importlib.reload(tembo.cli)
from tembo.cli.cli import _new_verify_name_exists
# act # act
verified_name = _new_verify_name_exists("some_scope") verified_name = _new_verify_name_exists("some_scope")
@@ -28,7 +30,7 @@ def test_new_verify_name_exists_success(shared_datadir):
def test_new_verify_name_exists_scope_not_found(shared_datadir): def test_new_verify_name_exists_scope_not_found(shared_datadir):
# arrange # arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success") os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success")
import tembo.cli importlib.reload(tembo.cli)
from tembo.cli.cli import _new_verify_name_exists from tembo.cli.cli import _new_verify_name_exists
# act # act
@@ -48,7 +50,7 @@ def test_new_verify_name_exists_scope_not_found(shared_datadir):
def test_new_verify_name_exists_empty_config(shared_datadir): def test_new_verify_name_exists_empty_config(shared_datadir):
# arrange # arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "empty") os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "empty")
import tembo.cli importlib.reload(tembo.cli)
from tembo.cli.cli import _new_verify_name_exists from tembo.cli.cli import _new_verify_name_exists
# act # act
@@ -68,7 +70,7 @@ def test_new_verify_name_exists_empty_config(shared_datadir):
def test_new_verify_name_exists_missing_config(shared_datadir): def test_new_verify_name_exists_missing_config(shared_datadir):
# arrange # arrange
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "missing") os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "missing")
import tembo.cli importlib.reload(tembo.cli)
from tembo.cli.cli import _new_verify_name_exists from tembo.cli.cli import _new_verify_name_exists
# act # act
@@ -85,11 +87,38 @@ def test_new_verify_name_exists_missing_config(shared_datadir):
del os.environ["TEMBO_CONFIG"] del os.environ["TEMBO_CONFIG"]
# def test_new_get_config_scope(shared_datadir): def test_new_get_config_scope_success(shared_datadir):
# # arrange # arrange
# os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success") os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "optional_keys")
# import tembo.cli importlib.reload(tembo.cli)
# # act # act
config_scope = _new_get_config_scope("some_scope")
# # assert # assert
assert config_scope == {
"name": "some_scope",
"path": "some_scope",
"filename": "{name}",
"extension": "md",
"example": None,
"template_filename": None,
}
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)
# act
with pytest.raises(
tembo.exceptions.MandatoryKeyNotFound
) as mandatory_key_not_found:
config_scope = _new_get_config_scope("some_scope")
# assert
assert (
str(mandatory_key_not_found.value) == "Key 'filename' not found in config.yml"
)