Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add about api #187

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add about api
andrew-codechimp committed Jul 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 308829850cd2686746e0dd13c8e1ba530dc2d08c
2 changes: 2 additions & 0 deletions src/aiomealie/__init__.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
)
from aiomealie.mealie import MealieClient
from aiomealie.models import (
About,
StartupInfo,
GroupSummary,
Theme,
@@ -30,6 +31,7 @@
)

__all__ = [
"About",
"MealieConnectionError",
"MealieError",
"MealieAuthenticationError",
8 changes: 7 additions & 1 deletion src/aiomealie/mealie.py
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
MealieBadRequestError,
)
from aiomealie.models import (
About,
GroupSummary,
Mealplan,
MealplanResponse,
@@ -164,8 +165,13 @@ async def get_startup_info(self) -> StartupInfo:
response = await self._get("api/app/about/startup-info")
return StartupInfo.from_json(response)

async def get_about(self) -> About:
"""Get about info."""
response = await self._get("api/app/about")
return About.from_json(response)

async def get_user_info(self) -> UserInfo:
"""Get startup info."""
"""Get user info."""
response = await self._get("api/users/self")
return UserInfo.from_json(response)

7 changes: 7 additions & 0 deletions src/aiomealie/models.py
Original file line number Diff line number Diff line change
@@ -39,6 +39,13 @@ class ShoppingItemsOrderBy(StrEnum):
POSITION = "position"


@dataclass
class About(DataClassORJSONMixin):
"""About model."""

version: str


@dataclass
class StartupInfo(DataClassORJSONMixin):
"""StartupInfo model."""
5 changes: 5 additions & 0 deletions tests/__snapshots__/test_mealie.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# serializer version: 1
# name: test_about
dict({
'version': 'v1.10.2',
})
# ---
# name: test_groups_self
dict({
'group_id': '0bf60b2e-ca89-42a9-94d4-8f67ca72b157',
3 changes: 3 additions & 0 deletions tests/fixtures/about.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "v1.10.2"
}
14 changes: 14 additions & 0 deletions tests/test_mealie.py
Original file line number Diff line number Diff line change
@@ -172,6 +172,20 @@ async def response_handler(_: str, **_kwargs: Any) -> CallbackResult:
assert await mealie_client.get_startup_info()


async def test_about(
responses: aioresponses,
mealie_client: MealieClient,
snapshot: SnapshotAssertion,
) -> None:
"""Test retrieving about."""
responses.get(
f"{MEALIE_URL}/api/app/about",
status=200,
body=load_fixture("about.json"),
)
assert await mealie_client.get_about() == snapshot


async def test_startup_info(
responses: aioresponses,
mealie_client: MealieClient,