Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 14 additions & 14 deletions tests/test_apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Asynchronous Python client for LaMetric TIME devices."""

from aioresponses import aioresponses
from yarl import URL

from demetriek import Chart, Goal, GoalData, LaMetricDevice, Simple

Expand All @@ -9,25 +10,23 @@

async def test_app_next(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test switching to the next app."""
responses.put(
f"{DEVICE_URL}/api/v2/device/apps/next",
status=200,
body=load_fixture("apps_next.json"),
)
url = f"{DEVICE_URL}/api/v2/device/apps/next"
responses.put(url, status=200, body=load_fixture("apps_next.json"))

await device.app_next()

assert ("PUT", URL(url)) in responses.requests


async def test_app_previous(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test switching to the previous app."""
responses.put(
f"{DEVICE_URL}/api/v2/device/apps/prev",
status=200,
body=load_fixture("apps_prev.json"),
)
url = f"{DEVICE_URL}/api/v2/device/apps/prev"
responses.put(url, status=200, body=load_fixture("apps_prev.json"))

await device.app_previous()

assert ("PUT", URL(url)) in responses.requests


async def test_apps(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test getting the installed apps."""
Expand Down Expand Up @@ -88,18 +87,19 @@ async def test_app(responses: aioresponses, device: LaMetricDevice) -> None:

async def test_activate_widget(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test showing a specific widget."""
responses.put(
url = (
f"{DEVICE_URL}/api/v2/device/apps/com.lametric.clock"
"/widgets/1_com.lametric.clock/activate",
status=200,
body=load_fixture("app_action.json"),
"/widgets/1_com.lametric.clock/activate"
)
responses.put(url, status=200, body=load_fixture("app_action.json"))

await device.activate_widget(
package="com.lametric.clock",
widget_id="1_com.lametric.clock",
)

assert ("PUT", URL(url)) in responses.requests


async def test_app_action(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test running an app action with parameters."""
Expand Down
9 changes: 9 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ async def test_set_audio(responses: aioresponses, device: LaMetricDevice) -> Non
assert audio.volume_limit
assert audio.volume_limit.range_min == 0
assert audio.volume_limit.range_max == 100


async def test_set_audio_mute(responses: aioresponses, device: LaMetricDevice) -> None:
"""Test a volume of zero is sent, and not mistaken for no volume at all."""
responses.put(AUDIO_URL, status=200, body=load_fixture("audio_set.json"))

await device.audio(volume=0)

assert request_json(responses, "PUT", AUDIO_URL) == {"volume": 0}
15 changes: 15 additions & 0 deletions tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ async def test_set_display(responses: aioresponses, device: LaMetricDevice) -> N
assert display.on is True


async def test_set_display_zero_and_off(
responses: aioresponses, device: LaMetricDevice
) -> None:
"""Test zero and off are sent, and not mistaken for no value at all."""
responses.put(DISPLAY_URL, status=200, body=load_fixture("display_set.json"))

await device.display(brightness=0, screensaver_enabled=False, on=False)

assert request_json(responses, "PUT", DISPLAY_URL) == {
"brightness": 0,
"screensaver": {"enabled": False},
"on": False,
}


async def test_set_display_screensaver_mode(
responses: aioresponses, device: LaMetricDevice
) -> None:
Expand Down
Loading