Skip to content

Commit 6b49be4

Browse files
committed
Test application startup with new TX_POWER config
1 parent 7609ebc commit 6b49be4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_application.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from asynctest import CoroutineMock
77

8+
import zigpy
89
import zigpy_znp.types as t
910
import zigpy_znp.commands as c
1011
import zigpy_znp.config as conf
@@ -79,12 +80,18 @@ async def callback():
7980

8081
def reply_to(self, request, responses):
8182
async def callback():
83+
callback.call_count += 1
84+
8285
for response in responses:
8386
await asyncio.sleep(0.1)
8487
self.send(response)
8588

89+
callback.call_count = 0
90+
8691
self.callback_for_response(request, lambda _: asyncio.create_task(callback()))
8792

93+
return callback
94+
8895
def ping_replier(self, request):
8996
self.send(c.SysCommands.Ping.Rsp(Capabilities=t.MTCapabilities(1625)))
9097

@@ -219,6 +226,21 @@ def register_endpoint(request):
219226
assert len(endpoints) == 5
220227

221228

229+
@pytest_mark_asyncio_timeout(seconds=3)
230+
async def test_application_startup_tx_power(application):
231+
app, znp_server = application
232+
233+
set_tx_power = znp_server.reply_once_to(
234+
request=c.SysCommands.SetTxPower.Req(TXPower=19),
235+
responses=[c.SysCommands.SetTxPower.Rsp(Status=t.Status.Success)],
236+
)
237+
238+
app.update_config({conf.CONF_ZNP_CONFIG: {conf.CONF_TX_POWER: 19}})
239+
240+
await app.startup(auto_form=False)
241+
await set_tx_power
242+
243+
222244
@pytest_mark_asyncio_timeout(seconds=3)
223245
async def test_permit_join(application):
224246
app, znp_server = application

0 commit comments

Comments
 (0)