From 156af4685510bac97a850b83d63f8337635db199 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Mon, 3 Jan 2022 02:00:46 +0000 Subject: [PATCH] tests: add tests for f5ea19e --- tests/conftest.py | 3 +++ .../panaetius_testing/config.yml | 2 ++ tests/test_config.py | 24 +++++-------------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a2b59da..1d08725 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,9 @@ def testing_config_contents(): "some_second_list": ["some", "second", "value"], "some_second_table": {"first": ["some", "first", "value"]}, "some_second_table_bools": {"bool": [True, False]}, + "third": { + "some_third_string": "some_third_value", + }, }, } } diff --git a/tests/data/without_logging/panaetius_testing/config.yml b/tests/data/without_logging/panaetius_testing/config.yml index 377f992..795908c 100644 --- a/tests/data/without_logging/panaetius_testing/config.yml +++ b/tests/data/without_logging/panaetius_testing/config.yml @@ -7,3 +7,5 @@ some_second_list: ["some", "second", "value"] some_second_table: { "first": ["some", "first", "value"] } some_second_table_bools: { "bool": [true, false] } + third: + some_third_string: some_third_value diff --git a/tests/test_config.py b/tests/test_config.py index 21b282c..6248b86 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -67,9 +67,7 @@ def test_config_file_without_header_dir_exists(header, shared_datadir): assert config._missing_config is False -def test_config_file_contents_read_success( - header, shared_datadir, testing_config_contents -): +def test_config_file_contents_read_success(header, shared_datadir, testing_config_contents): # arrange config_path = str(shared_datadir / "without_logging") @@ -101,11 +99,10 @@ def test_config_file_contents_read_success( "second_some_second_table_bools", {"bool": [True, False]}, ), + ("second.third.some_third_string", "second_third_some_third_string", "some_third_value"), ], ) -def test_get_value_from_key( - set_config_key, get_config_key, expected_value, header, shared_datadir -): +def test_get_value_from_key(set_config_key, get_config_key, expected_value, header, shared_datadir): """ Test the following: @@ -155,11 +152,7 @@ def test_key_level_too_deep(header, shared_datadir): panaetius.set_config(config, key) # assert - assert ( - str(key_error_too_deep.value) - == f"Your key of {key} can only be 2 levels deep maximum. " - f"You have 4" - ) + assert str(key_error_too_deep.value) == f"Your key of {key} can only be 3 levels deep maximum." def test_get_value_missing_key_from_default(header, shared_datadir): @@ -242,9 +235,7 @@ def test_missing_config_read_from_default(header, shared_datadir): ), ], ) -def test_missing_config_read_from_env_var( - env_value, expected_value, header, shared_datadir -): +def test_missing_config_read_from_env_var(env_value, expected_value, header, shared_datadir): # arrange config_path = str(shared_datadir / str(uuid4())) os.environ[f"{header.upper()}_MISSING_KEY_READ_FROM_ENV_VAR"] = env_value @@ -271,10 +262,7 @@ def test_missing_config_read_from_env_var_invalid_python(header): panaetius.set_config(config, "invalid_python") # assert - assert ( - str(invalid_python_exception.value) - == "a string without quotes is not valid Python." - ) + assert str(invalid_python_exception.value) == "a string without quotes is not valid Python." # cleanup del os.environ[f"{header.upper()}_INVALID_PYTHON"]