Skip to content

Commit 76ac2db

Browse files
tomer-wCopilot
andcommitted
Add test infrastructure and bump to v2026.3.1
Test infrastructure: - Add .devcontainer/devcontainer.json for Linux-based dev environment - Add requirements_test.txt with pytest-homeassistant-custom-component - Add pyproject.toml with asyncio_mode=auto for pytest - 30 config_flow tests: parsing, schemas, flow steps, options flow, validation - 8 hub tests: gateway creation, PGN filters, callbacks, status handling - 10 sensor tests: init, state, availability, TTL, update frequency - 70% overall code coverage (config_flow 92%, const 100%, sensor 71%) Version bump: - Update manifest.json to nmea2000==2026.3.1 and version 2026.3.1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3e60b6f commit 76ac2db

File tree

9 files changed

+748
-2
lines changed

9 files changed

+748
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "ha-nmea2000",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.13",
4+
"postCreateCommand": "pip install --upgrade pip && pip install -r requirements.txt && pip install -r requirements_test.txt",
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"charliermarsh.ruff",
9+
"ms-python.python",
10+
"ms-python.vscode-pylance",
11+
"ryanluker.vscode-coverage-gutters"
12+
],
13+
"settings": {
14+
"files.eol": "\n",
15+
"editor.tabSize": 4,
16+
"editor.formatOnSave": true,
17+
"[python]": {
18+
"editor.defaultFormatter": "charliermarsh.ruff"
19+
},
20+
"python.testing.pytestEnabled": true,
21+
"python.testing.pytestArgs": ["tests"]
22+
}
23+
}
24+
},
25+
"remoteUser": "vscode"
26+
}

custom_components/nmea2000/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"iot_class": "local_push",
1212
"issue_tracker": "https://github.com/tomer-w/ha-nmea2000/issues",
1313
"requirements": [
14-
"nmea2000==2026.3.0"
14+
"nmea2000==2026.3.1"
1515
],
16-
"version": "2026.3.0"
16+
"version": "2026.3.1"
1717
}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.pytest.ini_options]
2+
asyncio_mode = "auto"

requirements_test.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pytest
2+
pytest-asyncio
3+
pytest-homeassistant-custom-component

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Fixtures for ha-nmea2000 tests."""
2+
import pytest
3+
from unittest.mock import patch
4+
5+
pytest_plugins = ["pytest_homeassistant_custom_component"]
6+
7+
8+
@pytest.fixture(autouse=True)
9+
def auto_enable_custom_integrations(enable_custom_integrations):
10+
"""Enable loading custom integrations in all tests."""
11+
yield
12+
13+
14+
@pytest.fixture(autouse=True)
15+
def bypass_setup_entry():
16+
"""Prevent async_setup_entry from running during config flow tests."""
17+
with patch(
18+
"custom_components.nmea2000.async_setup_entry", return_value=True
19+
):
20+
yield
21+

0 commit comments

Comments
 (0)