mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Bump aioimmich to 0.8.0 (#145908)
This commit is contained in:
parent
ed9fd2c643
commit
3cfcf382da
@ -8,5 +8,5 @@
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["aioimmich"],
|
||||
"quality_scale": "silver",
|
||||
"requirements": ["aioimmich==0.7.0"]
|
||||
"requirements": ["aioimmich==0.8.0"]
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ class ImmichMediaSource(MediaSource):
|
||||
identifier=f"{identifier.unique_id}|albums|{album.album_id}",
|
||||
media_class=MediaClass.DIRECTORY,
|
||||
media_content_type=MediaClass.IMAGE,
|
||||
title=album.name,
|
||||
title=album.album_name,
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
thumbnail=f"/immich/{identifier.unique_id}/{album.thumbnail_asset_id}/thumbnail/image/jpg",
|
||||
thumbnail=f"/immich/{identifier.unique_id}/{album.album_thumbnail_asset_id}/thumbnail/image/jpg",
|
||||
)
|
||||
for album in albums
|
||||
]
|
||||
@ -160,18 +160,19 @@ class ImmichMediaSource(MediaSource):
|
||||
f"{identifier.unique_id}|albums|"
|
||||
f"{identifier.collection_id}|"
|
||||
f"{asset.asset_id}|"
|
||||
f"{asset.file_name}|"
|
||||
f"{asset.mime_type}"
|
||||
f"{asset.original_file_name}|"
|
||||
f"{mime_type}"
|
||||
),
|
||||
media_class=MediaClass.IMAGE,
|
||||
media_content_type=asset.mime_type,
|
||||
title=asset.file_name,
|
||||
media_content_type=mime_type,
|
||||
title=asset.original_file_name,
|
||||
can_play=False,
|
||||
can_expand=False,
|
||||
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{asset.mime_type}",
|
||||
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{mime_type}",
|
||||
)
|
||||
for asset in album_info.assets
|
||||
if asset.mime_type.startswith("image/")
|
||||
if (mime_type := asset.original_mime_type)
|
||||
and mime_type.startswith("image/")
|
||||
]
|
||||
|
||||
ret.extend(
|
||||
@ -181,18 +182,19 @@ class ImmichMediaSource(MediaSource):
|
||||
f"{identifier.unique_id}|albums|"
|
||||
f"{identifier.collection_id}|"
|
||||
f"{asset.asset_id}|"
|
||||
f"{asset.file_name}|"
|
||||
f"{asset.mime_type}"
|
||||
f"{asset.original_file_name}|"
|
||||
f"{mime_type}"
|
||||
),
|
||||
media_class=MediaClass.VIDEO,
|
||||
media_content_type=asset.mime_type,
|
||||
title=asset.file_name,
|
||||
media_content_type=mime_type,
|
||||
title=asset.original_file_name,
|
||||
can_play=True,
|
||||
can_expand=False,
|
||||
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/image/jpeg",
|
||||
)
|
||||
for asset in album_info.assets
|
||||
if asset.mime_type.startswith("video/")
|
||||
if (mime_type := asset.original_mime_type)
|
||||
and mime_type.startswith("video/")
|
||||
)
|
||||
|
||||
return ret
|
||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -280,7 +280,7 @@ aiohue==4.7.4
|
||||
aioimaplib==2.0.1
|
||||
|
||||
# homeassistant.components.immich
|
||||
aioimmich==0.7.0
|
||||
aioimmich==0.8.0
|
||||
|
||||
# homeassistant.components.apache_kafka
|
||||
aiokafka==0.10.0
|
||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -265,7 +265,7 @@ aiohue==4.7.4
|
||||
aioimaplib==2.0.1
|
||||
|
||||
# homeassistant.components.immich
|
||||
aioimmich==0.7.0
|
||||
aioimmich==0.8.0
|
||||
|
||||
# homeassistant.components.apache_kafka
|
||||
aiokafka==0.10.0
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""Common fixtures for the Immich tests."""
|
||||
|
||||
from collections.abc import AsyncGenerator, Generator
|
||||
from datetime import datetime
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from aioimmich import ImmichAlbums, ImmichAssests, ImmichServer, ImmichUsers
|
||||
@ -10,7 +9,7 @@ from aioimmich.server.models import (
|
||||
ImmichServerStatistics,
|
||||
ImmichServerStorage,
|
||||
)
|
||||
from aioimmich.users.models import AvatarColor, ImmichUser, UserStatus
|
||||
from aioimmich.users.models import ImmichUserObject
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.immich.const import DOMAIN
|
||||
@ -78,36 +77,58 @@ def mock_immich_assets() -> AsyncMock:
|
||||
def mock_immich_server() -> AsyncMock:
|
||||
"""Mock the Immich server."""
|
||||
mock = AsyncMock(spec=ImmichServer)
|
||||
mock.async_get_about_info.return_value = ImmichServerAbout(
|
||||
"v1.132.3",
|
||||
"some_url",
|
||||
False,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
mock.async_get_about_info.return_value = ImmichServerAbout.from_dict(
|
||||
{
|
||||
"version": "v1.132.3",
|
||||
"versionUrl": "https://github.com/immich-app/immich/releases/tag/v1.132.3",
|
||||
"licensed": False,
|
||||
"build": "14709928600",
|
||||
"buildUrl": "https://github.com/immich-app/immich/actions/runs/14709928600",
|
||||
"buildImage": "v1.132.3",
|
||||
"buildImageUrl": "https://github.com/immich-app/immich/pkgs/container/immich-server",
|
||||
"repository": "immich-app/immich",
|
||||
"repositoryUrl": "https://github.com/immich-app/immich",
|
||||
"sourceRef": "v1.132.3",
|
||||
"sourceCommit": "02994883fe3f3972323bb6759d0170a4062f5236",
|
||||
"sourceUrl": "https://github.com/immich-app/immich/commit/02994883fe3f3972323bb6759d0170a4062f5236",
|
||||
"nodejs": "v22.14.0",
|
||||
"exiftool": "13.00",
|
||||
"ffmpeg": "7.0.2-7",
|
||||
"libvips": "8.16.1",
|
||||
"imagemagick": "7.1.1-47",
|
||||
}
|
||||
)
|
||||
mock.async_get_storage_info.return_value = ImmichServerStorage(
|
||||
"294.2 GiB",
|
||||
"142.9 GiB",
|
||||
"136.3 GiB",
|
||||
315926315008,
|
||||
153400434688,
|
||||
146402975744,
|
||||
48.56,
|
||||
mock.async_get_storage_info.return_value = ImmichServerStorage.from_dict(
|
||||
{
|
||||
"diskSize": "294.2 GiB",
|
||||
"diskUse": "142.9 GiB",
|
||||
"diskAvailable": "136.3 GiB",
|
||||
"diskSizeRaw": 315926315008,
|
||||
"diskUseRaw": 153400406016,
|
||||
"diskAvailableRaw": 146403004416,
|
||||
"diskUsagePercentage": 48.56,
|
||||
}
|
||||
)
|
||||
mock.async_get_server_statistics.return_value = ImmichServerStatistics(
|
||||
27038, 1836, 119525451912, 54291170551, 65234281361
|
||||
mock.async_get_server_statistics.return_value = ImmichServerStatistics.from_dict(
|
||||
{
|
||||
"photos": 27038,
|
||||
"videos": 1836,
|
||||
"usage": 119525451912,
|
||||
"usagePhotos": 54291170551,
|
||||
"usageVideos": 65234281361,
|
||||
"usageByUser": [
|
||||
{
|
||||
"userId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"userName": "admin",
|
||||
"photos": 27038,
|
||||
"videos": 1836,
|
||||
"usage": 119525451912,
|
||||
"usagePhotos": 54291170551,
|
||||
"usageVideos": 65234281361,
|
||||
"quotaSizeInBytes": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
return mock
|
||||
|
||||
@ -116,23 +137,26 @@ def mock_immich_server() -> AsyncMock:
|
||||
def mock_immich_user() -> AsyncMock:
|
||||
"""Mock the Immich server."""
|
||||
mock = AsyncMock(spec=ImmichUsers)
|
||||
mock.async_get_my_user.return_value = ImmichUser(
|
||||
"e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"user@immich.local",
|
||||
"user",
|
||||
"",
|
||||
AvatarColor.PRIMARY,
|
||||
datetime.fromisoformat("2025-05-11T10:07:46.866Z"),
|
||||
"user",
|
||||
False,
|
||||
True,
|
||||
datetime.fromisoformat("2025-05-11T10:07:46.866Z"),
|
||||
None,
|
||||
None,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
UserStatus.ACTIVE,
|
||||
mock.async_get_my_user.return_value = ImmichUserObject.from_dict(
|
||||
{
|
||||
"id": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"email": "user@immich.local",
|
||||
"name": "user",
|
||||
"profileImagePath": "",
|
||||
"avatarColor": "primary",
|
||||
"profileChangedAt": "2025-05-11T10:07:46.866Z",
|
||||
"storageLabel": "user",
|
||||
"shouldChangePassword": True,
|
||||
"isAdmin": True,
|
||||
"createdAt": "2025-05-11T10:07:46.866Z",
|
||||
"deletedAt": None,
|
||||
"updatedAt": "2025-05-18T00:59:55.547Z",
|
||||
"oauthId": "",
|
||||
"quotaSizeInBytes": None,
|
||||
"quotaUsageInBytes": 119526467534,
|
||||
"status": "active",
|
||||
"license": None,
|
||||
}
|
||||
)
|
||||
return mock
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
"""Constants for the Immich integration tests."""
|
||||
|
||||
from aioimmich.albums.models import ImmichAlbum
|
||||
from aioimmich.assets.models import ImmichAsset
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
@ -26,27 +25,91 @@ MOCK_CONFIG_ENTRY_DATA = {
|
||||
CONF_VERIFY_SSL: False,
|
||||
}
|
||||
|
||||
MOCK_ALBUM_WITHOUT_ASSETS = ImmichAlbum(
|
||||
"721e1a4b-aa12-441e-8d3b-5ac7ab283bb6",
|
||||
"My Album",
|
||||
"This is my first great album",
|
||||
"0d03a7ad-ddc7-45a6-adee-68d322a6d2f5",
|
||||
1,
|
||||
[],
|
||||
)
|
||||
ALBUM_DATA = {
|
||||
"id": "721e1a4b-aa12-441e-8d3b-5ac7ab283bb6",
|
||||
"albumName": "My Album",
|
||||
"albumThumbnailAssetId": "0d03a7ad-ddc7-45a6-adee-68d322a6d2f5",
|
||||
"albumUsers": [],
|
||||
"assetCount": 1,
|
||||
"assets": [],
|
||||
"createdAt": "2025-05-11T10:13:22.799Z",
|
||||
"hasSharedLink": False,
|
||||
"isActivityEnabled": False,
|
||||
"ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"owner": {
|
||||
"id": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"email": "admin@immich.local",
|
||||
"name": "admin",
|
||||
"profileImagePath": "",
|
||||
"avatarColor": "primary",
|
||||
"profileChangedAt": "2025-05-11T10:07:46.866Z",
|
||||
},
|
||||
"shared": False,
|
||||
"updatedAt": "2025-05-17T11:26:03.696Z",
|
||||
}
|
||||
|
||||
MOCK_ALBUM_WITH_ASSETS = ImmichAlbum(
|
||||
"721e1a4b-aa12-441e-8d3b-5ac7ab283bb6",
|
||||
"My Album",
|
||||
"This is my first great album",
|
||||
"0d03a7ad-ddc7-45a6-adee-68d322a6d2f5",
|
||||
1,
|
||||
[
|
||||
ImmichAsset(
|
||||
"2e94c203-50aa-4ad2-8e29-56dd74e0eff4", "filename.jpg", "image/jpeg"
|
||||
),
|
||||
ImmichAsset(
|
||||
"2e65a5f2-db83-44c4-81ab-f5ff20c9bd7b", "filename.mp4", "video/mp4"
|
||||
),
|
||||
],
|
||||
MOCK_ALBUM_WITHOUT_ASSETS = ImmichAlbum.from_dict(ALBUM_DATA)
|
||||
|
||||
MOCK_ALBUM_WITH_ASSETS = ImmichAlbum.from_dict(
|
||||
{
|
||||
**ALBUM_DATA,
|
||||
"assets": [
|
||||
{
|
||||
"id": "2e94c203-50aa-4ad2-8e29-56dd74e0eff4",
|
||||
"deviceAssetId": "web-filename.jpg-1675185639000",
|
||||
"ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"deviceId": "WEB",
|
||||
"libraryId": None,
|
||||
"type": "IMAGE",
|
||||
"originalPath": "upload/upload/e7ef5713-9dab-4bd4-b899-715b0ca4379e/b4/b8/b4b8ef00-8a6d-4056-91ff-7f86dc66e427.jpg",
|
||||
"originalFileName": "filename.jpg",
|
||||
"originalMimeType": "image/jpeg",
|
||||
"thumbhash": "1igGFALX8mVGdHc5aChJf5nxNg==",
|
||||
"fileCreatedAt": "2023-01-31T17:20:37.085+00:00",
|
||||
"fileModifiedAt": "2023-01-31T17:20:39+00:00",
|
||||
"localDateTime": "2023-01-31T18:20:37.085+00:00",
|
||||
"updatedAt": "2025-05-11T10:13:49.590401+00:00",
|
||||
"isFavorite": False,
|
||||
"isArchived": False,
|
||||
"isTrashed": False,
|
||||
"duration": "0:00:00.00000",
|
||||
"exifInfo": {},
|
||||
"livePhotoVideoId": None,
|
||||
"people": [],
|
||||
"checksum": "HJm7TVOP80S+eiYZnAhWyRaB/Yc=",
|
||||
"isOffline": False,
|
||||
"hasMetadata": True,
|
||||
"duplicateId": None,
|
||||
"resized": True,
|
||||
},
|
||||
{
|
||||
"id": "2e65a5f2-db83-44c4-81ab-f5ff20c9bd7b",
|
||||
"deviceAssetId": "web-filename.mp4-1675185639000",
|
||||
"ownerId": "e7ef5713-9dab-4bd4-b899-715b0ca4379e",
|
||||
"deviceId": "WEB",
|
||||
"libraryId": None,
|
||||
"type": "IMAGE",
|
||||
"originalPath": "upload/upload/e7ef5713-9dab-4bd4-b899-715b0ca4379e/b4/b8/b4b8ef00-8a6d-4056-eeff-7f86dc66e427.mp4",
|
||||
"originalFileName": "filename.mp4",
|
||||
"originalMimeType": "video/mp4",
|
||||
"thumbhash": "1igGFALX8mVGdHc5aChJf5nxNg==",
|
||||
"fileCreatedAt": "2023-01-31T17:20:37.085+00:00",
|
||||
"fileModifiedAt": "2023-01-31T17:20:39+00:00",
|
||||
"localDateTime": "2023-01-31T18:20:37.085+00:00",
|
||||
"updatedAt": "2025-05-11T10:13:49.590401+00:00",
|
||||
"isFavorite": False,
|
||||
"isArchived": False,
|
||||
"isTrashed": False,
|
||||
"duration": "0:00:00.00000",
|
||||
"exifInfo": {},
|
||||
"livePhotoVideoId": None,
|
||||
"people": [],
|
||||
"checksum": "HJm7TVOP80S+eiYZnAhWyRaB/Yc=",
|
||||
"isOffline": False,
|
||||
"hasMetadata": True,
|
||||
"duplicateId": None,
|
||||
"resized": True,
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
|
@ -3,36 +3,48 @@
|
||||
dict({
|
||||
'data': dict({
|
||||
'server_about': dict({
|
||||
'build': None,
|
||||
'build_image': None,
|
||||
'build_image_url': None,
|
||||
'build_url': None,
|
||||
'exiftool': None,
|
||||
'ffmpeg': None,
|
||||
'imagemagick': None,
|
||||
'libvips': None,
|
||||
'build': '14709928600',
|
||||
'build_image': 'v1.132.3',
|
||||
'build_image_url': 'https://github.com/immich-app/immich/pkgs/container/immich-server',
|
||||
'build_url': 'https://github.com/immich-app/immich/actions/runs/14709928600',
|
||||
'exiftool': '13.00',
|
||||
'ffmpeg': '7.0.2-7',
|
||||
'imagemagick': '7.1.1-47',
|
||||
'libvips': '8.16.1',
|
||||
'licensed': False,
|
||||
'nodejs': None,
|
||||
'repository': None,
|
||||
'repository_url': None,
|
||||
'source_commit': None,
|
||||
'source_ref': None,
|
||||
'source_url': None,
|
||||
'nodejs': 'v22.14.0',
|
||||
'repository': 'immich-app/immich',
|
||||
'repository_url': 'https://github.com/immich-app/immich',
|
||||
'source_commit': '02994883fe3f3972323bb6759d0170a4062f5236',
|
||||
'source_ref': 'v1.132.3',
|
||||
'source_url': 'https://github.com/immich-app/immich/commit/02994883fe3f3972323bb6759d0170a4062f5236',
|
||||
'version': 'v1.132.3',
|
||||
'version_url': 'some_url',
|
||||
'version_url': 'https://github.com/immich-app/immich/releases/tag/v1.132.3',
|
||||
}),
|
||||
'server_storage': dict({
|
||||
'disk_available': '136.3 GiB',
|
||||
'disk_available_raw': 146402975744,
|
||||
'disk_available_raw': 146403004416,
|
||||
'disk_size': '294.2 GiB',
|
||||
'disk_size_raw': 315926315008,
|
||||
'disk_usage_percentage': 48.56,
|
||||
'disk_use': '142.9 GiB',
|
||||
'disk_use_raw': 153400434688,
|
||||
'disk_use_raw': 153400406016,
|
||||
}),
|
||||
'server_usage': dict({
|
||||
'photos': 27038,
|
||||
'usage': 119525451912,
|
||||
'usage_by_user': list([
|
||||
dict({
|
||||
'photos': 27038,
|
||||
'quota_size_in_bytes': None,
|
||||
'usage': 119525451912,
|
||||
'usage_photos': 54291170551,
|
||||
'usage_videos': 65234281361,
|
||||
'user_id': 'e7ef5713-9dab-4bd4-b899-715b0ca4379e',
|
||||
'user_name': 'admin',
|
||||
'videos': 1836,
|
||||
}),
|
||||
]),
|
||||
'usage_photos': 54291170551,
|
||||
'usage_videos': 65234281361,
|
||||
'videos': 1836,
|
||||
|
@ -55,7 +55,7 @@
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '136.34839630127',
|
||||
'state': '136.34842300415',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.someone_disk_size-entry]
|
||||
@ -225,7 +225,7 @@
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '142.865287780762',
|
||||
'state': '142.865261077881',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.someone_disk_used_by_photos-entry]
|
||||
|
Loading…
x
Reference in New Issue
Block a user