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