@@ -27,7 +27,7 @@ async def test_permit_join(device, fixed_joining_bug, mocker, make_application):
27
27
if fixed_joining_bug :
28
28
mocker .patch .object (device , "code_revision" , 20210708 )
29
29
30
- app , znp_server = make_application (server_cls = device )
30
+ app , znp_server = await make_application (server_cls = device )
31
31
32
32
# Handle us opening joins on the coordinator
33
33
permit_join_coordinator = znp_server .reply_once_to (
@@ -68,7 +68,7 @@ async def test_permit_join(device, fixed_joining_bug, mocker, make_application):
68
68
69
69
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
70
70
async def test_join_coordinator (device , make_application ):
71
- app , znp_server = make_application (server_cls = device )
71
+ app , znp_server = await make_application (server_cls = device )
72
72
73
73
# Handle us opening joins on the coordinator
74
74
permit_join_coordinator = znp_server .reply_once_to (
@@ -82,7 +82,7 @@ async def test_join_coordinator(device, make_application):
82
82
)
83
83
84
84
await app .startup (auto_form = False )
85
- await app .permit (node = app .ieee )
85
+ await app .permit (node = app .state . node_info . ieee )
86
86
87
87
await permit_join_coordinator
88
88
@@ -92,7 +92,7 @@ async def test_join_coordinator(device, make_application):
92
92
@pytest .mark .parametrize ("device" , FORMED_ZSTACK3_DEVICES )
93
93
@pytest .mark .parametrize ("permit_result" , [None , asyncio .TimeoutError ()])
94
94
async def test_permit_join_with_key (device , permit_result , make_application , mocker ):
95
- app , znp_server = make_application (server_cls = device )
95
+ app , znp_server = await make_application (server_cls = device )
96
96
97
97
# Consciot bulb
98
98
ieee = t .EUI64 .convert ("EC:1B:BD:FF:FE:54:4F:40" )
@@ -114,10 +114,6 @@ async def test_permit_join_with_key(device, permit_result, make_application, moc
114
114
],
115
115
)
116
116
117
- mocker .patch .object (
118
- app , "permit" , new = CoroutineMock (side_effect = [None , permit_result ])
119
- )
120
-
121
117
join_disable_install_code = znp_server .reply_once_to (
122
118
c .AppConfig .BDBSetJoinUsesInstallCodeKey .Req (BdbJoinUsesInstallCodeKey = False ),
123
119
responses = [
@@ -127,14 +123,16 @@ async def test_permit_join_with_key(device, permit_result, make_application, moc
127
123
128
124
await app .startup (auto_form = False )
129
125
126
+ mocker .patch .object (app , "permit" , new = CoroutineMock (side_effect = permit_result ))
127
+
130
128
with contextlib .nullcontext () if permit_result is None else pytest .raises (
131
129
asyncio .TimeoutError
132
130
):
133
131
await app .permit_with_key (node = ieee , code = code , time_s = 1 )
134
132
135
133
await bdb_add_install_code
136
134
await join_enable_install_code
137
- assert app .permit .call_count == 2
135
+ assert app .permit .call_count == 1
138
136
139
137
# The install code policy is reset right after
140
138
await join_disable_install_code
@@ -144,7 +142,7 @@ async def test_permit_join_with_key(device, permit_result, make_application, moc
144
142
145
143
@pytest .mark .parametrize ("device" , FORMED_ZSTACK3_DEVICES )
146
144
async def test_permit_join_with_invalid_key (device , make_application ):
147
- app , znp_server = make_application (server_cls = device )
145
+ app , znp_server = await make_application (server_cls = device )
148
146
149
147
# Consciot bulb
150
148
ieee = t .EUI64 .convert ("EC:1B:BD:FF:FE:54:4F:40" )
@@ -158,7 +156,7 @@ async def test_permit_join_with_invalid_key(device, make_application):
158
156
159
157
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
160
158
async def test_on_zdo_device_join (device , make_application , mocker ):
161
- app , znp_server = make_application (server_cls = device )
159
+ app , znp_server = await make_application (server_cls = device )
162
160
await app .startup (auto_form = False )
163
161
164
162
mocker .patch .object (app , "handle_join" )
@@ -178,7 +176,7 @@ async def test_on_zdo_device_join(device, make_application, mocker):
178
176
179
177
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
180
178
async def test_on_zdo_device_join_and_announce_fast (device , make_application , mocker ):
181
- app , znp_server = make_application (server_cls = device )
179
+ app , znp_server = await make_application (server_cls = device )
182
180
await app .startup (auto_form = False )
183
181
184
182
mocker .patch .object (app , "handle_join" )
@@ -215,7 +213,7 @@ async def test_on_zdo_device_join_and_announce_fast(device, make_application, mo
215
213
216
214
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
217
215
async def test_on_zdo_device_join_and_announce_slow (device , make_application , mocker ):
218
- app , znp_server = make_application (server_cls = device )
216
+ app , znp_server = await make_application (server_cls = device )
219
217
await app .startup (auto_form = False )
220
218
221
219
mocker .patch .object (app , "handle_join" )
@@ -253,7 +251,7 @@ async def test_on_zdo_device_join_and_announce_slow(device, make_application, mo
253
251
254
252
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
255
253
async def test_new_device_join_and_bind_complex (device , make_application , mocker ):
256
- app , znp_server = make_application (server_cls = device )
254
+ app , znp_server = await make_application (server_cls = device )
257
255
await app .startup (auto_form = False )
258
256
259
257
nwk = 0x6A7C
@@ -504,7 +502,7 @@ def bind_req_callback(request):
504
502
ep = device .endpoints [request .SrcEndpoint ]
505
503
assert cluster in ep .in_clusters or cluster in ep .out_clusters
506
504
507
- assert request .Address .ieee == app .ieee
505
+ assert request .Address .ieee == app .state . node_info . ieee
508
506
assert request .Address .addrmode == 0x03
509
507
510
508
# Make sure the endpoint profiles match up
@@ -530,7 +528,7 @@ def bind_req_callback(request):
530
528
531
529
@pytest .mark .parametrize ("device" , FORMED_DEVICES )
532
530
async def test_unknown_device_discovery (device , make_application , mocker ):
533
- app , znp_server = make_application (server_cls = device )
531
+ app , znp_server = await make_application (server_cls = device )
534
532
await app .startup (auto_form = False )
535
533
536
534
mocker .spy (app , "handle_join" )
@@ -604,4 +602,4 @@ async def test_unknown_device_discovery(device, make_application, mocker):
604
602
assert new_dev .nwk == new_nwk
605
603
assert new_dev .ieee == new_ieee
606
604
607
- await app .pre_shutdown ()
605
+ await app .shutdown ()
0 commit comments