Skip to content

Commit d1bc90e

Browse files
committed
Merge branch 'main' into dependabot/github_actions/codecov/codecov-action-5
2 parents 18ff928 + 15df28a commit d1bc90e

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

aioraven/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def convert_date(raw: Optional[str]) -> Optional[date]:
5858

5959

6060
def convert_date_code(raw: Optional[str]) -> Optional[Tuple[date, str]]:
61-
if raw is not None:
61+
if raw is not None and not all(ch == '\xff' for ch in raw):
6262
if len(raw) >= 9:
6363
date = convert_date(raw[:8])
6464
if date is not None:

aioraven/protocols.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ def __init__(
4343
self._closed = self._loop.create_future()
4444

4545
def _reset(self) -> None:
46-
self._parser = Et.XMLPullParser(events=('end',))
47-
self._parser.feed(b'<?xml version="1.0" encoding="ASCII"?><root>')
4846
self._stash = b''
47+
self._parser = Et.XMLPullParser(events=('end',))
48+
self._parser.feed(
49+
b'<?xml version="1.0" encoding="Windows-1252"?><root>')
4950

5051
def _get_close_waiter(self, stream: Any) -> Future[None]:
5152
return self._closed

test/test_data.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,44 @@ async def test_get_device_info():
352352
date_code=(date(2022, 1, 1), 'a0000042'))
353353

354354

355+
@pytest.mark.asyncio
356+
async def test_get_device_info_date_code_filler():
357+
"""
358+
Verify behavior of the ``get_device_info`` command with a filler value for
359+
date_code.
360+
"""
361+
responses = {
362+
b'<Command><Name>get_device_info</Name></Command>':
363+
b'<DeviceInfo>'
364+
b' <DeviceMacId>0x0123456789ABCDEF</DeviceMacId>'
365+
b' <InstallCode>0xABCDEF0123456789</InstallCode>'
366+
b' <LinkKey>0xABCDEF0123456789ABCDEF0123456789</LinkKey>'
367+
b' <FWVersion>1.21g</FWVersion>'
368+
b' <HWVersion>5.55 rev 2</HWVersion>'
369+
b' <ImageType>Mocked</ImageType>'
370+
b' <Manufacturer>aioraven</Manufacturer>'
371+
b' <ModelId>Python</ModelId>'
372+
b' <DateCode>\xff\xff\xff\xff\xff\xff\xff\xff'
373+
b'\xff\xff\xff\xff\xff\xff\xff\xff</DateCode>'
374+
b'</DeviceInfo>',
375+
}
376+
377+
async with mock_device(responses) as (host, port):
378+
async with RAVEnNetworkDevice(host, port) as dut:
379+
actual = await dut.get_device_info()
380+
381+
assert actual == DeviceInfo(
382+
device_mac_id=bytes.fromhex('0123456789ABCDEF'),
383+
install_code=bytes.fromhex('ABCDEF0123456789'),
384+
link_key=bytes.fromhex('ABCDEF0123456789ABCDEF0123456789'),
385+
fw_version='1.21g',
386+
hw_version='5.55 rev 2',
387+
image_type='Mocked',
388+
manufacturer='aioraven',
389+
model_id='Python',
390+
date_code=None)
391+
392+
355393
@pytest.mark.asyncio
356394
async def test_get_instantaneous_demand():
357395
"""Verify behavior of the ``get_instantaneous_demand`` command."""

0 commit comments

Comments
 (0)