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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
CACHE_VERSION: 1
DEFAULT_PYTHON: 3.7
DEFAULT_PYTHON: 3.8
PRE_COMMIT_HOME: ~/.cache/pre-commit

jobs:
Expand All @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, "3.10"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v2
Expand All @@ -35,7 +35,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
restore-keys: |
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
- name: Create Python virtual environment
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -240,7 +240,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -271,7 +271,7 @@ jobs:
needs: prepare-base
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, "3.10"]
name: >-
Run tests Python ${{ matrix.python-version }}
steps:
Expand All @@ -290,7 +290,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
key: >-
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
steps.python.outputs.python-version }}-${{
hashFiles('requirements_test.txt') }}
hashFiles('requirements_test.txt', 'setup.py') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
version: 3.7
version: 3.8
- name: Install wheel
run: >-
pip install wheel
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
author_email="schmidt.d@aon.at",
license="GPL-3.0",
packages=find_packages(exclude=["tests"]),
install_requires=["pyserial-asyncio", "zigpy>=0.47.0"],
tests_require=["pytest", "pytest-asyncio>=0.17", "asynctest"],
install_requires=["zigpy>=0.51.0"],
tests_require=["pytest", "asynctest"],
)
85 changes: 79 additions & 6 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _fake_args(arg_type):
return list(arg_type)[0] # Pick the first enum value
elif issubclass(arg_type, t.DeconzAddressEndpoint):
addr = t.DeconzAddressEndpoint()
addr.address_mode = t.ADDRESS_MODE.NWK
addr.address_mode = t.AddressMode.NWK
addr.address = t.uint8_t(0)
addr.endpoint = t.uint8_t(0)
return addr
Expand Down Expand Up @@ -242,11 +242,34 @@ async def test_aps_data_confirm(api, monkeypatch):

success = True

def mock_cmd(*args, **kwargs):
res = asyncio.Future()
if success:
res.set_result([7, 0x22, 0x11, sentinel.dst_addr, 1, 0x00, 0, 0, 0, 0])
return asyncio.wait_for(res, timeout=deconz_api.COMMAND_TIMEOUT)
async def mock_cmd(*args, **kwargs):
if not success:
raise asyncio.TimeoutError()

dst = t.DeconzAddressEndpoint()
dst.address_mode = t.AddressMode.NWK
dst.address = 0x26FF
dst.endpoint = 1

rsp = [
12,
(
deconz_api.DeviceState.APSDE_DATA_REQUEST_SLOTS_AVAILABLE
| deconz_api.DeviceState.APSDE_DATA_INDICATION
| deconz_api.DeviceState.APSDE_DATA_CONFIRM
| 2
),
98,
dst,
1,
deconz_api.TXStatus.SUCCESS,
0,
0,
0,
0,
]
api._handle_aps_data_confirm(rsp)
return rsp

api._command = mock_cmd
api._data_confirm = True
Expand Down Expand Up @@ -586,3 +609,53 @@ async def test_connection_lost(api):
api.connection_lost(err)

app.connection_lost.assert_called_once_with(err)


async def test_aps_data_indication(api):
dst = t.DeconzAddress()
dst.address_mode = t.AddressMode.NWK
dst.address = 0x0000

src = t.DeconzAddress()
src.address_mode = t.AddressMode.NWK
src.address = 0xC643

data = b"\x18\x1f\x01\x04\x00\x00B\x12Third Reality, Inc\x05\x00\x00B\t3RSP019BZ"

packet = [
63,
(deconz_api.DeviceState.APSDE_DATA_REQUEST_SLOTS_AVAILABLE | 2),
dst,
1,
src,
1,
260,
0,
data,
0,
175,
255,
186,
25,
78,
3,
-47,
]

api._handle_aps_data_indication(packet)

api._app.handle_rx.assert_called_once_with(
src=src,
src_ep=1,
dst=dst,
dst_ep=1,
profile_id=260,
cluster_id=0x0000,
data=data,
lqi=255,
rssi=-47,
)

# No error is thrown when the app is disconnected
api._app = None
api._handle_aps_data_indication(packet)
Loading