diff --git a/.gitignore b/.gitignore index 8a2867d..968cf96 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ __pycache__ .venv* coverage.xml +# config +.env # Home Assistant configuration config/* diff --git a/poetry.lock b/poetry.lock index 7ec9bd1..057db6c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2127,6 +2127,20 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.0.1" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"}, + {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "python-slugify" version = "8.0.1" @@ -2938,4 +2952,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.13" -content-hash = "b0f27e0835ed5e266e5a5e22a42843d74518b5d4b62ff7aec23711847446c95b" +content-hash = "883f3d29a49f8558adcf41b2bf56d0c24d96b209dfb0a0b9476a3395501ba8f8" diff --git a/pyproject.toml b/pyproject.toml index 4fa3b82..d6b0b9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ optional = true [tool.poetry.group.test.dependencies] pytest-homeassistant-custom-component = "^0.13.91" +python-dotenv = "^1.0.1" [tool.pytest.ini_options] testpaths = "tests" diff --git a/scripts/setup b/scripts/setup index 1d18ef9..9f110fb 100755 --- a/scripts/setup +++ b/scripts/setup @@ -12,6 +12,6 @@ poetry self add poetry-plugin-export poetry config warnings.export false #poetry config virtualenvs.in-project true poetry completions bash >> ~/.bash_completion -poetry install +poetry install --with dev --with test echo alias py=python >> ~/.bash_aliases diff --git a/tests/conftest.py b/tests/conftest.py index 5bb4f5f..f2397ea 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,6 @@ +import os + +from dotenv import load_dotenv from unittest.mock import patch import pytest @@ -12,13 +15,7 @@ def auto_enable_custom_integrations(enable_custom_integrations): yield -# This fixture is used to prevent HomeAssistant from attempting to create and dismiss persistent -# notifications. These calls would fail without this fixture since the persistent_notification -# integration is never loaded during a test. -@pytest.fixture(name="skip_notifications", autouse=True) -def skip_notifications_fixture(): - """Skip notification calls.""" - with patch("homeassistant.components.persistent_notification.async_create"), patch( - "homeassistant.components.persistent_notification.async_dismiss" - ): - yield +@pytest.fixture(autouse=True) +def auto_enable_local_env(): + if os.path.exists(".env"): + load_dotenv(os.path.abspath(".env"))