Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Integration Tests

on: [push]

jobs:
integration-test:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.14
uses: actions/setup-python@v3
with:
python-version: "3.14"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_integration_tests.txt

- name: Run integration tests
run: |
pytest tests/integration_tests/ -v
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:

- name: Analysing the code with pylint
run: |
pylint --fail-under=9 --max-line-length=120 --disable=import-error,wrong-import-position,wrong-import-order,too-many-instance-attributes,too-many-locals,too-many-arguments,too-few-public-methods --ignore-paths=^test/.*$ $(git ls-files '*.py')
pylint --fail-under=9 --max-line-length=120 --disable=import-error,wrong-import-position,wrong-import-order,too-many-instance-attributes,too-many-locals,too-many-arguments,too-few-public-methods --ignore-paths=^tests/.*$ $(git ls-files '*.py')
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:

- name: Run tests
run: |
python -m unittest -v
python -m unittest discover -s tests/unit_tests -v
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/htmlcov/
/.coverage
__pycache__/
*.pyc
/htmlcov/
/.coverage
custom_components/
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
asyncio_mode = auto
1 change: 1 addition & 0 deletions requirements_integration_tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-homeassistant-custom-component==0.13.318
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

coverage run --omit='test/*' -m unittest; coverage html
coverage run --omit='tests/unit_tests/*' -m unittest discover -s tests/unit_tests; coverage html
File renamed without changes.
61 changes: 61 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""pytest-homeassistant-custom-component conftest for SSH Command integration tests.

This file wires the component (which lives at the repo root, not inside a
conventional ``custom_components/`` sub-directory) into Home Assistant's custom
component loader, and provides shared fixtures used by all integration tests.
"""

from __future__ import annotations

import sys
from pathlib import Path

import pytest

# ---------------------------------------------------------------------------
# Path setup
# ---------------------------------------------------------------------------

# The repo root IS the component package (content_in_root: true).
REPO_ROOT = Path(__file__).parent.parent.parent

# Make the repo root importable so Python can see it as a top-level package.
_REPO_PARENT = str(REPO_ROOT.parent)
if _REPO_PARENT not in sys.path:
sys.path.insert(0, _REPO_PARENT)

# ---------------------------------------------------------------------------
# custom_components symlink
# ---------------------------------------------------------------------------
# Home Assistant's component loader imports the ``custom_components`` package
# and iterates its subdirectories. We create a symlink
# <repo_root>/custom_components/ssh_command -> <repo_root>
# so that HA can discover and load the component as ``custom_components.ssh_command``.

_CUSTOM_COMPONENTS = REPO_ROOT / "custom_components"
_CUSTOM_COMPONENTS.mkdir(exist_ok=True)
(_CUSTOM_COMPONENTS / "__init__.py").touch()

_SYMLINK = _CUSTOM_COMPONENTS / "ssh_command"
if not _SYMLINK.exists():
_SYMLINK.symlink_to(REPO_ROOT)

# Make custom_components importable from within the repo root.
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))


# ---------------------------------------------------------------------------
# Fixtures
# ---------------------------------------------------------------------------


@pytest.fixture
def expected_lingering_timers() -> bool:
"""Allow any timers registered during setup to linger during teardown."""
return True


@pytest.fixture(autouse=True)
def auto_enable_custom_integrations(enable_custom_integrations):
"""Enable custom integrations for every test in this package."""
Loading
Loading