1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-19 06:50:15 +01:00
Files
Tomasz Dylewski a82205fed7 Added PAJ GPS integration (#165070)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Josef Zweck <josef@zweck.dev>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2026-05-07 17:04:19 +02:00

67 lines
1.9 KiB
Python

"""Common fixtures for PAJ GPS integration tests."""
from __future__ import annotations
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
from pajgps_api.models.auth import AuthResponse
from pajgps_api.models.device import Device
from pajgps_api.models.trackpoint import TrackPoint
import pytest
from homeassistant.components.paj_gps.const import DOMAIN
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from tests.common import MockConfigEntry, load_json_object_fixture
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Prevent the PAJ GPS integration from setting up during config flow tests."""
with patch(
"homeassistant.components.paj_gps.async_setup_entry",
return_value=True,
) as mock:
yield mock
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return a mock config entry for PAJ GPS."""
return MockConfigEntry(
domain=DOMAIN,
title="test@example.com",
unique_id="42",
data={
CONF_EMAIL: "test@example.com",
CONF_PASSWORD: "secret",
},
)
@pytest.fixture
def mock_paj_gps_api() -> Generator[AsyncMock]:
"""Mock PajGpsApi for PAJ GPS integration tests."""
with (
patch(
"homeassistant.components.paj_gps.coordinator.PajGpsApi",
autospec=True,
) as mock_api_cls,
patch(
"homeassistant.components.paj_gps.config_flow.PajGpsApi",
new=mock_api_cls,
),
):
api = mock_api_cls.return_value
api.login.return_value = AuthResponse(
userID=42, token="test_token", refresh_token="test_refresh"
)
api.get_devices.return_value = [
Device(**load_json_object_fixture("device.json", DOMAIN))
]
api.get_all_last_positions.return_value = [
TrackPoint(**load_json_object_fixture("trackpoint.json", DOMAIN))
]
yield api