mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Update aioazuredevops to 2.1.1 (#119720)
* Update aioazuredevops to 2.1.1 * Update tests
This commit is contained in:
parent
c75db797d0
commit
f1f82ffbf8
@ -5,9 +5,9 @@ from datetime import timedelta
|
||||
import logging
|
||||
from typing import Final
|
||||
|
||||
from aioazuredevops.builds import DevOpsBuild
|
||||
from aioazuredevops.client import DevOpsClient
|
||||
from aioazuredevops.core import DevOpsProject
|
||||
from aioazuredevops.models.builds import Build
|
||||
from aioazuredevops.models.core import Project
|
||||
import aiohttp
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -44,7 +44,7 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
|
||||
|
||||
client: DevOpsClient
|
||||
organization: str
|
||||
project: DevOpsProject
|
||||
project: Project
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -88,7 +88,7 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
|
||||
async def get_project(
|
||||
self,
|
||||
project: str,
|
||||
) -> DevOpsProject | None:
|
||||
) -> Project | None:
|
||||
"""Get the project."""
|
||||
return await self.client.get_project(
|
||||
self.organization,
|
||||
@ -96,7 +96,7 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
|
||||
)
|
||||
|
||||
@ado_exception_none_handler
|
||||
async def _get_builds(self, project_name: str) -> list[DevOpsBuild] | None:
|
||||
async def _get_builds(self, project_name: str) -> list[Build] | None:
|
||||
"""Get the builds."""
|
||||
return await self.client.get_builds(
|
||||
self.organization,
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from aioazuredevops.builds import DevOpsBuild
|
||||
from aioazuredevops.core import DevOpsProject
|
||||
from aioazuredevops.models.builds import Build
|
||||
from aioazuredevops.models.core import Project
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
@ -11,5 +11,5 @@ class AzureDevOpsData:
|
||||
"""Class describing Azure DevOps data."""
|
||||
|
||||
organization: str
|
||||
project: DevOpsProject
|
||||
builds: list[DevOpsBuild]
|
||||
project: Project
|
||||
builds: list[Build]
|
||||
|
@ -6,5 +6,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/azure_devops",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["aioazuredevops"],
|
||||
"requirements": ["aioazuredevops==2.0.0"]
|
||||
"requirements": ["aioazuredevops==2.1.1"]
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ from datetime import datetime
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from aioazuredevops.builds import DevOpsBuild
|
||||
from aioazuredevops.models.builds import Build
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
@ -32,8 +32,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class AzureDevOpsBuildSensorEntityDescription(SensorEntityDescription):
|
||||
"""Class describing Azure DevOps base build sensor entities."""
|
||||
|
||||
attr_fn: Callable[[DevOpsBuild], dict[str, Any] | None] = lambda _: None
|
||||
value_fn: Callable[[DevOpsBuild], datetime | StateType]
|
||||
attr_fn: Callable[[Build], dict[str, Any] | None] = lambda _: None
|
||||
value_fn: Callable[[Build], datetime | StateType]
|
||||
|
||||
|
||||
BASE_BUILD_SENSOR_DESCRIPTIONS: tuple[AzureDevOpsBuildSensorEntityDescription, ...] = (
|
||||
@ -133,7 +133,7 @@ async def async_setup_entry(
|
||||
) -> None:
|
||||
"""Set up Azure DevOps sensor based on a config entry."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
initial_builds: list[DevOpsBuild] = coordinator.data.builds
|
||||
initial_builds: list[Build] = coordinator.data.builds
|
||||
|
||||
async_add_entities(
|
||||
AzureDevOpsBuildSensor(
|
||||
@ -162,13 +162,13 @@ class AzureDevOpsBuildSensor(AzureDevOpsEntity, SensorEntity):
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self.item_key = item_key
|
||||
self._attr_unique_id = f"{self.coordinator.data.organization}_{self.build.project.project_id}_{self.build.definition.build_id}_{description.key}"
|
||||
self._attr_unique_id = f"{self.coordinator.data.organization}_{self.build.project.id}_{self.build.definition.build_id}_{description.key}"
|
||||
self._attr_translation_placeholders = {
|
||||
"definition_name": self.build.definition.name
|
||||
}
|
||||
|
||||
@property
|
||||
def build(self) -> DevOpsBuild:
|
||||
def build(self) -> Build:
|
||||
"""Return the build."""
|
||||
return self.coordinator.data.builds[self.item_key]
|
||||
|
||||
|
@ -207,7 +207,7 @@ aioasuswrt==1.4.0
|
||||
aioautomower==2024.6.0
|
||||
|
||||
# homeassistant.components.azure_devops
|
||||
aioazuredevops==2.0.0
|
||||
aioazuredevops==2.1.1
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.9.0
|
||||
|
@ -186,7 +186,7 @@ aioasuswrt==1.4.0
|
||||
aioautomower==2024.6.0
|
||||
|
||||
# homeassistant.components.azure_devops
|
||||
aioazuredevops==2.0.0
|
||||
aioazuredevops==2.1.1
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.9.0
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
from typing import Final
|
||||
|
||||
from aioazuredevops.builds import DevOpsBuild, DevOpsBuildDefinition
|
||||
from aioazuredevops.core import DevOpsProject
|
||||
from aioazuredevops.models.builds import Build, BuildDefinition
|
||||
from aioazuredevops.models.core import Project
|
||||
|
||||
from homeassistant.components.azure_devops.const import CONF_ORG, CONF_PAT, CONF_PROJECT
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -28,20 +28,19 @@ FIXTURE_REAUTH_INPUT = {
|
||||
}
|
||||
|
||||
|
||||
DEVOPS_PROJECT = DevOpsProject(
|
||||
project_id="1234",
|
||||
DEVOPS_PROJECT = Project(
|
||||
id="1234",
|
||||
name=PROJECT,
|
||||
description="Test Description",
|
||||
url=f"https://dev.azure.com/{ORGANIZATION}/{PROJECT}",
|
||||
state="wellFormed",
|
||||
revision=1,
|
||||
visibility="private",
|
||||
last_updated=None,
|
||||
default_team=None,
|
||||
links=None,
|
||||
)
|
||||
|
||||
DEVOPS_BUILD_DEFINITION = DevOpsBuildDefinition(
|
||||
DEVOPS_BUILD_DEFINITION = BuildDefinition(
|
||||
build_id=9876,
|
||||
name="CI",
|
||||
url=f"https://dev.azure.com/{ORGANIZATION}/{PROJECT}/_apis/build/definitions/1",
|
||||
@ -51,7 +50,7 @@ DEVOPS_BUILD_DEFINITION = DevOpsBuildDefinition(
|
||||
revision=1,
|
||||
)
|
||||
|
||||
DEVOPS_BUILD = DevOpsBuild(
|
||||
DEVOPS_BUILD = Build(
|
||||
build_id=5678,
|
||||
build_number="1",
|
||||
status="completed",
|
||||
@ -68,13 +67,13 @@ DEVOPS_BUILD = DevOpsBuild(
|
||||
links=None,
|
||||
)
|
||||
|
||||
DEVOPS_BUILD_MISSING_DATA = DevOpsBuild(
|
||||
DEVOPS_BUILD_MISSING_DATA = Build(
|
||||
build_id=6789,
|
||||
definition=DEVOPS_BUILD_DEFINITION,
|
||||
project=DEVOPS_PROJECT,
|
||||
)
|
||||
|
||||
DEVOPS_BUILD_MISSING_PROJECT_DEFINITION = DevOpsBuild(
|
||||
DEVOPS_BUILD_MISSING_PROJECT_DEFINITION = Build(
|
||||
build_id=9876,
|
||||
)
|
||||
|
||||
|
@ -33,7 +33,7 @@ async def mock_devops_client() -> AsyncGenerator[MagicMock]:
|
||||
devops_client.get_project.return_value = DEVOPS_PROJECT
|
||||
devops_client.get_builds.return_value = [DEVOPS_BUILD]
|
||||
devops_client.get_build.return_value = DEVOPS_BUILD
|
||||
devops_client.get_work_items_ids_all.return_value = None
|
||||
devops_client.get_work_item_ids.return_value = None
|
||||
devops_client.get_work_items.return_value = None
|
||||
|
||||
yield devops_client
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from aioazuredevops.core import DevOpsProject
|
||||
import aiohttp
|
||||
|
||||
from homeassistant import config_entries
|
||||
@ -218,9 +217,6 @@ async def test_reauth_flow(
|
||||
|
||||
mock_devops_client.authorize.return_value = True
|
||||
mock_devops_client.authorized = True
|
||||
mock_devops_client.get_project.return_value = DevOpsProject(
|
||||
"abcd-abcd-abcd-abcd", FIXTURE_USER_INPUT[CONF_PROJECT]
|
||||
)
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user