mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 07:45:44 +00:00
adding latest
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import importlib
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
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():
|
||||
@@ -12,8 +15,7 @@ def test_cli_page_is_saved_success():
|
||||
def test_new_verify_name_exists_success(shared_datadir):
|
||||
# arrange
|
||||
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success")
|
||||
import tembo.cli
|
||||
from tembo.cli.cli import _new_verify_name_exists
|
||||
importlib.reload(tembo.cli)
|
||||
|
||||
# act
|
||||
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):
|
||||
# arrange
|
||||
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
|
||||
@@ -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):
|
||||
# arrange
|
||||
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
|
||||
|
||||
# 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):
|
||||
# arrange
|
||||
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
|
||||
|
||||
# act
|
||||
@@ -85,11 +87,38 @@ def test_new_verify_name_exists_missing_config(shared_datadir):
|
||||
del os.environ["TEMBO_CONFIG"]
|
||||
|
||||
|
||||
# def test_new_get_config_scope(shared_datadir):
|
||||
# # arrange
|
||||
# os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "success")
|
||||
# import tembo.cli
|
||||
def test_new_get_config_scope_success(shared_datadir):
|
||||
# arrange
|
||||
os.environ["TEMBO_CONFIG"] = str(shared_datadir / "config" / "optional_keys")
|
||||
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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user