Skip to content

Commit c51de2b

Browse files
committed
Separate RebootOptions and test options
1 parent a572071 commit c51de2b

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

aiohasupervisor/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from aiohasupervisor.models.host import (
5353
HostInfo,
5454
HostOptions,
55+
RebootOptions,
5556
Service,
5657
ServiceState,
5758
ShutdownOptions,
@@ -179,6 +180,7 @@
179180
"PartialRestoreOptions",
180181
"HostInfo",
181182
"HostOptions",
183+
"RebootOptions",
182184
"Service",
183185
"ServiceState",
184186
"ShutdownOptions",

aiohasupervisor/models/host.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class ShutdownOptions(Request):
6868
force: bool
6969

7070

71+
@dataclass(frozen=True, slots=True)
72+
class RebootOptions(Request):
73+
"""RebootOptions model."""
74+
75+
force: bool
76+
77+
7178
@dataclass(frozen=True, slots=True)
7279
class HostOptions(Request):
7380
"""HostOptions model."""

tests/test_host.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from datetime import UTC, datetime
44

55
from aioresponses import aioresponses
6+
import pytest
67
from yarl import URL
78

89
from aiohasupervisor import SupervisorClient
9-
from aiohasupervisor.models import HostOptions
10+
from aiohasupervisor.models import HostOptions, RebootOptions, ShutdownOptions
1011

1112
from . import load_fixture
1213
from .const import SUPERVISOR_URL
@@ -46,21 +47,27 @@ async def test_host_info(
4647
assert result.startup_time == 1.966311
4748

4849

50+
@pytest.mark.parametrize("options", [None, RebootOptions(force=True)])
4951
async def test_host_reboot(
50-
responses: aioresponses, supervisor_client: SupervisorClient
52+
responses: aioresponses,
53+
supervisor_client: SupervisorClient,
54+
options: RebootOptions | None,
5155
) -> None:
5256
"""Test host reboot API."""
5357
responses.post(f"{SUPERVISOR_URL}/host/reboot", status=200)
54-
assert await supervisor_client.host.reboot() is None
58+
assert await supervisor_client.host.reboot(options) is None
5559
assert responses.requests.keys() == {("POST", URL(f"{SUPERVISOR_URL}/host/reboot"))}
5660

5761

62+
@pytest.mark.parametrize("options", [None, ShutdownOptions(force=True)])
5863
async def test_host_shutdown(
59-
responses: aioresponses, supervisor_client: SupervisorClient
64+
responses: aioresponses,
65+
supervisor_client: SupervisorClient,
66+
options: ShutdownOptions | None,
6067
) -> None:
6168
"""Test host shutdown API."""
6269
responses.post(f"{SUPERVISOR_URL}/host/shutdown", status=200)
63-
assert await supervisor_client.host.shutdown() is None
70+
assert await supervisor_client.host.shutdown(options) is None
6471
assert responses.requests.keys() == {
6572
("POST", URL(f"{SUPERVISOR_URL}/host/shutdown"))
6673
}

0 commit comments

Comments
 (0)