diff --git a/.vscode/settings.json b/.vscode/settings.json index a17eb69..5b28c72 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,7 @@ "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "flake8.args": [ - "--extend-exclude=app/tests/*.py system_tests/*.py ha_addons/ha_addon/tests/*.py" + "--extend-exclude=app/tests/*.py,system_tests/*.py,ha_addons/ha_addon/tests/*.py" ], "sonarlint.connectedMode.project": { "connectionId": "s-allius", diff --git a/ha_addons/ha_addon/tests/test_create_config_toml.py b/ha_addons/ha_addon/tests/test_create_config_toml.py index 3776b41..3fd715e 100644 --- a/ha_addons/ha_addon/tests/test_create_config_toml.py +++ b/ha_addons/ha_addon/tests/test_create_config_toml.py @@ -8,7 +8,6 @@ from home.create_config_toml import create_config from test_config import ConfigComplete, ConfigMinimum - class FakeBuffer: rd = bytearray() wr = str() @@ -53,6 +52,7 @@ def patch_open(): with patch('builtins.open', new_open) as conn: yield conn + @pytest.fixture def ConfigTomlEmpty(): return { @@ -79,6 +79,7 @@ def ConfigTomlEmpty(): }, } + def test_no_config(patch_open, ConfigTomlEmpty): _ = patch_open test_buffer.wr = "" @@ -87,6 +88,7 @@ def test_no_config(patch_open, ConfigTomlEmpty): cnf = tomllib.loads(test_buffer.wr) assert cnf == ConfigTomlEmpty + def test_empty_config(patch_open, ConfigTomlEmpty): _ = patch_open test_buffer.wr = "" @@ -95,6 +97,7 @@ def test_empty_config(patch_open, ConfigTomlEmpty): cnf = tomllib.loads(test_buffer.wr) assert cnf == ConfigTomlEmpty + def test_full_config(patch_open, ConfigComplete): _ = patch_open test_buffer.wr = "" @@ -154,6 +157,7 @@ def test_full_config(patch_open, ConfigComplete): validated = Config.conf_schema.validate(cnf) assert validated == ConfigComplete + def test_minimum_config(patch_open, ConfigMinimum): _ = patch_open test_buffer.wr = ""