-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from dougiteixeira/tests-add-config_flow-p1
Add basic tests for config flow (part 1)
- Loading branch information
Showing
13 changed files
with
1,868 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tool.mypy] | ||
exclude = ["venv/"] | ||
platform = "linux" | ||
show_error_codes = true | ||
follow_imports = "normal" | ||
local_partial_types = true | ||
strict_equality = true | ||
no_implicit_optional = true | ||
warn_incomplete_stub = true | ||
warn_redundant_casts = true | ||
warn_unused_configs = true | ||
warn_unused_ignores = true | ||
disable_error_code = ["import-untyped"] | ||
extra_checks = false | ||
check_untyped_defs = true | ||
disallow_incomplete_defs = true | ||
disallow_subclassing_any = true | ||
disallow_untyped_calls = true | ||
disallow_untyped_decorators = true | ||
disallow_untyped_defs = true | ||
warn_return_any = true | ||
warn_unreachable = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
colorlog==6.9.0 | ||
homeassistant==2024.12.1 | ||
homeassistant==2024.12.3 | ||
pip>=21.3.1 | ||
proxmoxer==2.1.0 | ||
ruff==0.8.2 | ||
ruff==0.8.2 | ||
pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-r requirements.txt | ||
colorlog~=6.9 | ||
flake8~=7.1 | ||
flake8-docstrings~=1.7 | ||
fnv-hash-fast | ||
mypy~=1.13 | ||
psutil-home-assistant==0.0.1 | ||
pylint~=3.3 | ||
pylint-strict-informational==0.1 | ||
pytest>=7.2 | ||
pytest-cov | ||
pytest-homeassistant-custom-component | ||
pytest-asyncio>=0.20 | ||
tzdata | ||
ruff~=0.8 | ||
anyio | ||
pytest-asyncio | ||
pytest-tornasync | ||
pytest-trio | ||
proxmoxer | ||
pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[tool:pytest] | ||
testpaths = tests | ||
norecursedirs = .git | ||
addopts = | ||
--strict-markers | ||
--cov=custom_components | ||
asyncio_mode = auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Tests for Proxmox VE Custom Integration.""" | ||
|
||
from unittest.mock import patch | ||
|
||
from homeassistant.core import HomeAssistant | ||
from pytest_homeassistant_custom_component.common import MockConfigEntry | ||
|
||
|
||
async def async_init_integration( | ||
hass: HomeAssistant, mock_config_entry: MockConfigEntry | ||
) -> None: | ||
"""Set up the La Marzocco integration for testing.""" | ||
mock_config_entry.add_to_hass(hass) | ||
await hass.config_entries.async_setup(mock_config_entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
|
||
def patch_async_setup_entry(return_value=True): | ||
"""Patch async setup entry to return True.""" | ||
return patch( | ||
"custom_components.proxmoxve.async_setup_entry", | ||
return_value=return_value, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# pylint: disable=protected-access,redefined-outer-name | ||
"""Global fixtures for integration.""" | ||
|
||
# Fixtures allow you to replace functions with a Mock object. You can perform | ||
# many options via the Mock to reflect a particular behavior from the original | ||
# function that you want to see without going through the function's actual logic. | ||
# Fixtures can either be passed into tests as parameters, or if autouse=True, they | ||
# will automatically be used across all tests. | ||
# | ||
# Fixtures that are defined in conftest.py are available across all tests. You can also | ||
# define fixtures within a particular test file to scope them locally. | ||
# | ||
# pytest_homeassistant_custom_component provides some fixtures that are provided by | ||
# Home Assistant core. You can find those fixture definitions here: | ||
# https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/blob/master/pytest_homeassistant_custom_component/common.py | ||
# | ||
# See here for more info: https://docs.pytest.org/en/latest/fixture.html (note that | ||
# pytest includes fixtures OOB which you can use as defined on this page) | ||
|
||
import pytest | ||
from homeassistant.core import HomeAssistant | ||
from pytest_homeassistant_custom_component.common import MockConfigEntry | ||
|
||
from . import async_init_integration | ||
|
||
pytest_plugins = "pytest_homeassistant_custom_component" # pylint: disable=invalid-name | ||
|
||
|
||
# This fixture enables loading custom integrations in all tests. | ||
# Remove to enable selective use of this fixture | ||
@pytest.fixture(autouse=True) | ||
def auto_enable_custom_integrations(enable_custom_integrations): | ||
"""Automatically enable loading custom integrations in all tests.""" | ||
return | ||
|
||
|
||
@pytest.fixture | ||
async def init_integration( | ||
hass: HomeAssistant, mock_config_entry: MockConfigEntry | ||
) -> MockConfigEntry: | ||
"""Set up the Proxmox VE integration for testing.""" | ||
await async_init_integration(hass, mock_config_entry) | ||
|
||
return mock_config_entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"test_key": "test_value" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""Tests changes to common module.""" | ||
|
||
import json | ||
|
||
from pytest_homeassistant_custom_component.common import load_fixture | ||
|
||
|
||
def test_load_fixture(): | ||
"""Test load fixture.""" | ||
data = json.loads(load_fixture("test_data.json")) | ||
assert data == {"test_key": "test_value"} |
Oops, something went wrong.