Skip to content

Commit b2e2b9d

Browse files
authored
Merge pull request #128 from puddly/rc
0.16.0 Release
2 parents 81cff21 + 93f588a commit b2e2b9d

File tree

7 files changed

+105
-185
lines changed

7 files changed

+105
-185
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@master
13-
- name: Set up Python 3.7
13+
- name: Set up Python 3.8
1414
uses: actions/setup-python@v1
1515
with:
16-
version: 3.7
16+
version: 3.8
1717
- name: Install wheel
1818
run: >-
1919
pip install wheel

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
author="Russell Cloran",
1717
author_email="rcloran@gmail.com",
1818
license="GPL-3.0",
19-
packages=find_packages(exclude=["*.tests"]),
20-
install_requires=["pyserial-asyncio", "zigpy>=0.47.0"],
19+
packages=find_packages(exclude=["tests", "tests.*"]),
20+
install_requires=["zigpy>=0.51.0"],
2121
tests_require=["pytest", "asynctest", "pytest-asyncio"],
2222
)

tests/test_application.py

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,18 @@ async def test_broadcast(app):
217217
assert app._api._command.call_args[0][9] == data
218218

219219
app._api._command.return_value = xbee_t.TXStatus.ADDRESS_NOT_FOUND
220-
r = await app.broadcast(profile, cluster, src_ep, dst_ep, grpid, radius, tsn, data)
221-
assert r[0] != xbee_t.TXStatus.SUCCESS
220+
221+
with pytest.raises(zigpy.exceptions.DeliveryError):
222+
r = await app.broadcast(
223+
profile, cluster, src_ep, dst_ep, grpid, radius, tsn, data
224+
)
222225

223226
app._api._command.side_effect = asyncio.TimeoutError
224-
r = await app.broadcast(profile, cluster, src_ep, dst_ep, grpid, radius, tsn, data)
225-
assert r[0] != xbee_t.TXStatus.SUCCESS
227+
228+
with pytest.raises(zigpy.exceptions.DeliveryError):
229+
r = await app.broadcast(
230+
profile, cluster, src_ep, dst_ep, grpid, radius, tsn, data
231+
)
226232

227233

228234
async def test_get_association_state(app):
@@ -242,6 +248,14 @@ async def test_form_network(app):
242248
async def mock_at_command(cmd, *args):
243249
if cmd == "MY":
244250
return 0x0000
251+
if cmd == "OI":
252+
return 0x1234
253+
elif cmd == "ID":
254+
return 0x1234567812345678
255+
elif cmd == "SL":
256+
return 0x11223344
257+
elif cmd == "SH":
258+
return 0x55667788
245259
elif cmd == "WR":
246260
app._api.coordinator_started_event.set()
247261
elif cmd == "CE" and legacy_module:
@@ -393,25 +407,13 @@ async def test_permit(app):
393407

394408

395409
async def _test_request(
396-
app,
397-
expect_reply=True,
398-
send_success=True,
399-
send_timeout=False,
400-
is_end_device=True,
401-
node_desc=True,
402-
**kwargs
410+
app, expect_reply=True, send_success=True, send_timeout=False, **kwargs
403411
):
404412
seq = 123
405413
nwk = 0x2345
406414
ieee = t.EUI64(b"\x01\x02\x03\x04\x05\x06\x07\x08")
407415
dev = app.add_device(ieee, nwk)
408416

409-
if node_desc:
410-
dev.node_desc = mock.MagicMock()
411-
dev.node_desc.is_end_device = is_end_device
412-
else:
413-
dev.node_desc = None
414-
415417
def _mock_command(
416418
cmdname, ieee, nwk, src_ep, dst_ep, cluster, profile, radius, options, data
417419
):
@@ -437,42 +439,34 @@ def _mock_command(
437439
)
438440

439441

440-
async def test_request_with_reply(app):
441-
r = await _test_request(app, expect_reply=True, send_success=True)
442+
async def test_request_with_ieee(app):
443+
r = await _test_request(app, use_ieee=True, send_success=True)
442444
assert r[0] == 0
443445

444446

445-
async def test_request_without_node_desc(app):
446-
r = await _test_request(app, expect_reply=True, send_success=True, node_desc=False)
447+
async def test_request_with_reply(app):
448+
r = await _test_request(app, expect_reply=True, send_success=True)
447449
assert r[0] == 0
448450

449451

450452
async def test_request_send_timeout(app):
451-
r = await _test_request(app, send_timeout=True)
452-
assert r[0] != 0
453+
with pytest.raises(zigpy.exceptions.DeliveryError):
454+
await _test_request(app, send_timeout=True)
453455

454456

455457
async def test_request_send_fail(app):
456-
r = await _test_request(app, send_success=False)
457-
assert r[0] != 0
458+
with pytest.raises(zigpy.exceptions.DeliveryError):
459+
await _test_request(app, send_success=False)
458460

459461

460462
async def test_request_extended_timeout(app):
461-
is_end_device = False
462-
r = await _test_request(app, True, True, is_end_device=is_end_device)
463+
r = await _test_request(app, True, True, extended_timeout=False)
463464
assert r[0] == xbee_t.TXStatus.SUCCESS
464465
assert app._api._command.call_count == 1
465466
assert app._api._command.call_args[0][8] & 0x40 == 0x00
466467
app._api._command.reset_mock()
467468

468-
r = await _test_request(app, True, True, node_desc=False)
469-
assert r[0] == xbee_t.TXStatus.SUCCESS
470-
assert app._api._command.call_count == 1
471-
assert app._api._command.call_args[0][8] & 0x40 == 0x40
472-
app._api._command.reset_mock()
473-
474-
is_end_device = True
475-
r = await _test_request(app, True, True, is_end_device=is_end_device)
469+
r = await _test_request(app, True, True, extended_timeout=True)
476470
assert r[0] == xbee_t.TXStatus.SUCCESS
477471
assert app._api._command.call_count == 1
478472
assert app._api._command.call_args[0][8] & 0x40 == 0x40
@@ -570,10 +564,26 @@ async def test_mrequest_with_reply(app):
570564

571565

572566
async def test_mrequest_send_timeout(app):
573-
r = await _test_mrequest(app, send_timeout=True)
574-
assert r[0] != 0
567+
with pytest.raises(zigpy.exceptions.DeliveryError):
568+
await _test_mrequest(app, send_timeout=True)
575569

576570

577571
async def test_mrequest_send_fail(app):
578-
r = await _test_mrequest(app, send_success=False)
579-
assert r[0] != 0
572+
with pytest.raises(zigpy.exceptions.DeliveryError):
573+
await _test_mrequest(app, send_success=False)
574+
575+
576+
async def test_reset_network_info(app):
577+
async def mock_at_command(cmd, *args):
578+
if cmd == "NR":
579+
return 0x00
580+
581+
return None
582+
583+
app._api._at_command = mock.MagicMock(
584+
spec=XBee._at_command, side_effect=mock_at_command
585+
)
586+
587+
await app.reset_network_info()
588+
589+
app._api._at_command.assert_called_once_with("NR", 0)

zigpy_xbee/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MAJOR_VERSION = 0
2-
MINOR_VERSION = 15
2+
MINOR_VERSION = 16
33
PATCH_VERSION = "0"
44
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
55
__version__ = f"{__short_version__}.{PATCH_VERSION}"

zigpy_xbee/types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,11 @@ class DiscoveryStatus(uint8_t, UndefinedEnum):
239239
ADDRESS_AND_ROUTE = 0x03
240240
EXTENDED_TIMEOUT = 0x40
241241
_UNDEFINED = 0x00
242+
243+
244+
class TXOptions(zigpy.types.bitmap8):
245+
NONE = 0x00
246+
247+
Disable_Retries_and_Route_Repair = 0x01
248+
Enable_APS_Encryption = 0x20
249+
Use_Extended_TX_Timeout = 0x40

zigpy_xbee/uart.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import logging
33
from typing import Any, Dict
44

5-
import serial
6-
import serial_asyncio
5+
import zigpy.serial
76

87
from zigpy_xbee.config import CONF_DEVICE_BAUDRATE, CONF_DEVICE_PATH
98

@@ -169,13 +168,11 @@ async def connect(device_config: Dict[str, Any], api, loop=None) -> Gateway:
169168
connected_future = asyncio.Future()
170169
protocol = Gateway(api, connected_future)
171170

172-
transport, protocol = await serial_asyncio.create_serial_connection(
171+
transport, protocol = await zigpy.serial.create_serial_connection(
173172
loop,
174173
lambda: protocol,
175174
url=device_config[CONF_DEVICE_PATH],
176175
baudrate=device_config[CONF_DEVICE_BAUDRATE],
177-
parity=serial.PARITY_NONE,
178-
stopbits=serial.STOPBITS_ONE,
179176
xonxoff=False,
180177
)
181178

0 commit comments

Comments
 (0)