FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix test coverage · python-kasa/python-kasa@aef9930 · GitHub

Repository navigation

Commit aef9930

Browse files
committed
Fix test coverage
1 parent 0e5ded6 commit aef9930

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎tests/smartcam/test_smartcamdevice.py‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import base64
6-
from datetime import UTC, datetime
6+
from datetime import UTC, datetime, timedelta, tzinfo
77
from unittest.mock import AsyncMock, PropertyMock, patch
88
from zoneinfo import ZoneInfo
99

@@ -193,6 +193,30 @@ async def test_set_time_formats_timezone_parametrized(
193193
assert call.args[1]["system"]["basic"]["timezone"] == expected_timezone
194194

195195

196+
@device_smartcam
197+
async def test_set_time_format_none_offset_defaults_to_utc(dev: Device):
198+
"""Test SmartCam set_time handles None offset as UTC+00:00."""
199+
200+
class NoneOffsetTz(tzinfo):
201+
def utcoffset(self, dt: datetime | None) -> timedelta | None:
202+
return None
203+
204+
def dst(self, dt: datetime | None) -> timedelta | None:
205+
return None
206+
207+
def tzname(self, dt: datetime | None) -> str | None:
208+
return "NoneOffset"
209+
210+
module = dev.modules[Module.Time]
211+
with patch.object(module, "call", AsyncMock(return_value={})) as call_mock:
212+
await module.set_time(datetime(2024, 1, 15, 12, 0, tzinfo=NoneOffsetTz()))
213+
214+
call_mock.assert_awaited_once()
215+
call = call_mock.await_args_list[0]
216+
assert call.args[0] == "setTimezone"
217+
assert call.args[1]["system"]["basic"]["timezone"] == "UTC+00:00"
218+
219+
196220
@device_smartcam
197221
async def test_wifi_join_typeerror_on_non_rsa_key(dev: SmartCamDevice):
198222
dev._networks = [

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL