Bump python-opensky to 0.2.1 (#102467)

This commit is contained in:
Joost Lekkerkerker 2023-10-22 22:00:14 +02:00 committed by GitHub
parent e3b238861d
commit 2dfb3ba693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 21 deletions

View File

@ -5,5 +5,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/opensky",
"iot_class": "cloud_polling",
"requirements": ["python-opensky==0.2.0"]
"requirements": ["python-opensky==0.2.1"]
}

View File

@ -2163,7 +2163,7 @@ python-mystrom==2.2.0
python-opendata-transport==0.3.0
# homeassistant.components.opensky
python-opensky==0.2.0
python-opensky==0.2.1
# homeassistant.components.otbr
# homeassistant.components.thread

View File

@ -1610,7 +1610,7 @@ python-myq==3.1.13
python-mystrom==2.2.0
# homeassistant.components.opensky
python-opensky==0.2.0
python-opensky==0.2.1
# homeassistant.components.otbr
# homeassistant.components.thread

View File

@ -1,10 +1,9 @@
"""Opensky tests."""
import json
from unittest.mock import patch
from python_opensky import StatesResponse
from tests.common import load_fixture
from tests.common import load_json_object_fixture
def patch_setup_entry() -> bool:
@ -16,5 +15,5 @@ def patch_setup_entry() -> bool:
def get_states_response_fixture(fixture: str) -> StatesResponse:
"""Return the states response from json."""
json_fixture = load_fixture(fixture)
return StatesResponse.parse_obj(json.loads(json_fixture))
states_json = load_json_object_fixture(fixture)
return StatesResponse.from_api(states_json)

View File

@ -1,10 +1,8 @@
"""Configure tests for the OpenSky integration."""
from collections.abc import Awaitable, Callable
import json
from unittest.mock import patch
import pytest
from python_opensky import StatesResponse
from homeassistant.components.opensky.const import (
CONF_ALTITUDE,
@ -21,7 +19,9 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from tests.common import MockConfigEntry, load_fixture
from . import get_states_response_fixture
from tests.common import MockConfigEntry
ComponentSetup = Callable[[MockConfigEntry], Awaitable[None]]
@ -88,10 +88,9 @@ async def mock_setup_integration(
async def func(mock_config_entry: MockConfigEntry) -> None:
mock_config_entry.add_to_hass(hass)
json_fixture = load_fixture("opensky/states.json")
with patch(
"python_opensky.OpenSky.get_states",
return_value=StatesResponse.parse_obj(json.loads(json_fixture)),
return_value=get_states_response_fixture("opensky/states.json"),
):
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()

View File

@ -1,10 +1,8 @@
"""OpenSky sensor tests."""
from datetime import timedelta
import json
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
from python_opensky import StatesResponse
from syrupy import SnapshotAssertion
from homeassistant.components.opensky.const import (
@ -18,19 +16,19 @@ from homeassistant.core import Event, HomeAssistant
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component
from . import get_states_response_fixture
from .conftest import ComponentSetup
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
from tests.common import MockConfigEntry, async_fire_time_changed
LEGACY_CONFIG = {Platform.SENSOR: [{CONF_PLATFORM: DOMAIN, CONF_RADIUS: 10.0}]}
async def test_legacy_migration(hass: HomeAssistant) -> None:
"""Test migration from yaml to config flow."""
json_fixture = load_fixture("opensky/states.json")
with patch(
"python_opensky.OpenSky.get_states",
return_value=StatesResponse.parse_obj(json.loads(json_fixture)),
return_value=get_states_response_fixture("opensky/states.json"),
):
assert await async_setup_component(hass, Platform.SENSOR, LEGACY_CONFIG)
await hass.async_block_till_done()
@ -85,10 +83,6 @@ async def test_sensor_updating(
"""Test updating sensor."""
await setup_integration(config_entry)
def get_states_response_fixture(fixture: str) -> StatesResponse:
json_fixture = load_fixture(fixture)
return StatesResponse.parse_obj(json.loads(json_fixture))
events = []
async def event_listener(event: Event) -> None: