コード例 #1
0
async def test_get_node_descriptor(app: application.ControllerApplication):
    await device_annce(app)
    device = app.get_device(nwk=53322)

    fut = asyncio.Future()
    fut.set_result([0, "message send success"])
    app._api.request_raw = mock.MagicMock(return_value=fut)

    payload = {
        "srcaddr": 53322,
        "status": 0,
        "nwkaddr": 0,
        "logicaltype_cmplxdescavai_userdescavai": 0,
        "apsflags_freqband": 0,
        "maccapflags": 0,
        "manufacturercode": 1234,
        "maxbuffersize": 0,
        "maxintransfersize": 0,
        "servermask": 0,
        "maxouttransfersize": 0,
        "descriptorcap": 0,
    }
    obj = ZpiObject.from_command(5, "nodeDescRsp", payload)
    frame = obj.to_unpi_frame()

    async def nested():
        await asyncio.sleep(0)
        app._api.data_received(frame)

    await asyncio.wait([device.get_node_descriptor(), nested()], timeout=0.2)

    assert isinstance(device.node_desc, zdo_t.NodeDescriptor)
    assert 1234 == device.node_desc.manufacturer_code
コード例 #2
0
ファイル: test_application.py プロジェクト: Hedda/zigpy-cc
async def test_get_node_descriptor(app: application.ControllerApplication):
    await device_annce(app)
    device = app.get_device(nwk=53322)

    fut = asyncio.Future()
    fut.set_result([0, 'message send success'])
    app._api.request_raw = mock.MagicMock(return_value=fut)

    payload = {'srcaddr': 53322, 'status': 0, 'nwkaddr': 0, 'logicaltype_cmplxdescavai_userdescavai': 0,
               'apsflags_freqband': 0, 'maccapflags': 0, 'manufacturercode': 1234, 'maxbuffersize': 0,
               'maxintransfersize': 0, 'servermask': 0, 'maxouttransfersize': 0, 'descriptorcap': 0}
    obj = ZpiObject.from_command(2, 5, 'nodeDescRsp', payload)
    frame = obj.to_unpi_frame()

    async def nested():
        await asyncio.sleep(0)
        app._api.data_received(frame)

    await asyncio.wait([
        device.get_node_descriptor(),
        nested(),
    ], timeout=0.2)

    assert isinstance(device.node_desc, zdo_t.NodeDescriptor)
    assert device.node_desc.manufacturer_code == 1234
コード例 #3
0
ファイル: test_application.py プロジェクト: nixent/zigpy-cc
async def test_request(app: application.ControllerApplication):
    await device_annce(app)
    device = app.get_device(nwk=53322)

    fut = asyncio.Future()
    fut.set_result(None)
    app._api.request_raw = mock.MagicMock(return_value=fut)

    res = await app.request(device, 0, zdo_t.ZDOCmd.Node_Desc_req, 0, 0, 1,
                            b"\x01\xa2\x2e")

    assert len(app._api._waiters) == 1
    assert res == (0, "message send success")
コード例 #4
0
ファイル: test_application.py プロジェクト: puddly/zigpy-cc
async def test_request(app: application.ControllerApplication):
    await device_annce(app)
    device = app.get_device(nwk=53322)

    fut = asyncio.Future()
    fut.set_result(None)
    app._api.request_raw = mock.MagicMock(return_value=fut)

    res = await app.request(device, 0, zdo_t.ZDOCmd.Node_Desc_req, 0, 0, 1,
                            b"\x01\xa2\x2e")

    assert len(app._api._waiters) == 1
    assert (
        "SREQ ZDO nodeDescReq tsn: 1 {'dstaddr': 0xd04a, 'nwkaddrofinterest': 0x2ea2}"
        == str(app._api.request_raw.call_args[0][0]))
    assert res == (0, "message send success")
コード例 #5
0
ファイル: test_application.py プロジェクト: nixent/zigpy-cc
async def test_read_attributes(app: application.ControllerApplication):
    await device_annce(app)
    device = app.get_device(nwk=53322)