Skip to content

Commit 778904b

Browse files
committed
Uppercase command subsystem names (Util => UTIL, App => APP)
1 parent 9134329 commit 778904b

File tree

11 files changed

+61
-61
lines changed

11 files changed

+61
-61
lines changed

tests/api/test_request.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def test_cleanup_timeout_internal(connected_znp):
5555
assert not znp._listeners
5656

5757
with pytest.raises(asyncio.TimeoutError):
58-
await znp.request(c.Util.TimeAlive.Req())
58+
await znp.request(c.UTIL.TimeAlive.Req())
5959

6060
# We should be cleaned up
6161
assert not znp._listeners
@@ -69,7 +69,7 @@ async def test_cleanup_timeout_external(connected_znp):
6969
# This request will timeout because we didn't send anything back
7070
with pytest.raises(asyncio.TimeoutError):
7171
async with async_timeout.timeout(0.1):
72-
await znp.request(c.Util.TimeAlive.Req())
72+
await znp.request(c.UTIL.TimeAlive.Req())
7373

7474
# We should be cleaned up
7575
assert not znp._listeners
@@ -84,7 +84,7 @@ async def test_callback_rsp_cleanup_timeout_external(connected_znp):
8484
with pytest.raises(asyncio.TimeoutError):
8585
async with async_timeout.timeout(0.1):
8686
await znp.request_callback_rsp(
87-
request=c.Util.TimeAlive.Req(),
87+
request=c.UTIL.TimeAlive.Req(),
8888
callback=c.SYS.ResetInd.Callback(partial=True),
8989
)
9090

@@ -103,7 +103,7 @@ async def test_callback_rsp_cleanup_timeout_internal(background, connected_znp):
103103
# This request will timeout because we didn't send anything back
104104
with pytest.raises(asyncio.TimeoutError):
105105
await znp.request_callback_rsp(
106-
request=c.Util.TimeAlive.Req(),
106+
request=c.UTIL.TimeAlive.Req(),
107107
callback=c.SYS.ResetInd.Callback(partial=True),
108108
background=background,
109109
)
@@ -122,7 +122,7 @@ async def test_callback_rsp_cleanup_background_error(connected_znp):
122122
# This request will timeout because we didn't send anything back
123123
with pytest.raises(asyncio.TimeoutError):
124124
await znp.request_callback_rsp(
125-
request=c.Util.TimeAlive.Req(),
125+
request=c.UTIL.TimeAlive.Req(),
126126
callback=c.SYS.ResetInd.Callback(partial=True),
127127
background=True,
128128
)
@@ -141,7 +141,7 @@ async def test_callback_rsp_cleanup_background_timeout(connected_znp):
141141
# This request will timeout because we didn't send anything back
142142
with pytest.raises(asyncio.TimeoutError):
143143
await znp.request_callback_rsp(
144-
request=c.Util.TimeAlive.Req(),
144+
request=c.UTIL.TimeAlive.Req(),
145145
callback=c.SYS.ResetInd.Callback(partial=True),
146146
background=True,
147147
)
@@ -158,15 +158,15 @@ async def test_callback_rsp_cleanup_concurrent(connected_znp, event_loop, mocker
158158
assert not znp._listeners
159159

160160
def send_responses():
161-
znp_server.send(c.Util.TimeAlive.Rsp(Seconds=123))
162-
znp_server.send(c.Util.TimeAlive.Rsp(Seconds=456))
161+
znp_server.send(c.UTIL.TimeAlive.Rsp(Seconds=123))
162+
znp_server.send(c.UTIL.TimeAlive.Rsp(Seconds=456))
163163
znp_server.send(c.SYS.OSALTimerExpired.Callback(Id=0xAB))
164164
znp_server.send(c.SYS.OSALTimerExpired.Callback(Id=0xCD))
165165

166166
event_loop.call_soon(send_responses)
167167

168168
callback_rsp = await znp.request_callback_rsp(
169-
request=c.Util.TimeAlive.Req(),
169+
request=c.UTIL.TimeAlive.Req(),
170170
callback=c.SYS.OSALTimerExpired.Callback(partial=True),
171171
)
172172

@@ -178,7 +178,7 @@ def send_responses():
178178
# Even though all four requests were sent in the same tick, they should be handled
179179
# correctly by request_callback_rsp and in the correct order
180180
assert znp._unhandled_command.mock_calls == [
181-
mocker.call(c.Util.TimeAlive.Rsp(Seconds=456)),
181+
mocker.call(c.UTIL.TimeAlive.Rsp(Seconds=456)),
182182
mocker.call(c.SYS.OSALTimerExpired.Callback(Id=0xCD)),
183183
]
184184

tests/api/test_response.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async def test_response_callback_simple(connected_znp, event_loop, mocker):
213213
# being implicitly marked as "asyncio"
214214
async def test_command_deduplication_simple():
215215
c1 = c.SYS.Ping.Rsp(partial=True)
216-
c2 = c.Util.TimeAlive.Rsp(Seconds=12)
216+
c2 = c.UTIL.TimeAlive.Rsp(Seconds=12)
217217

218218
assert _deduplicate_commands([]) == ()
219219
assert _deduplicate_commands([c1]) == (c1,)
@@ -230,8 +230,8 @@ async def test_command_deduplication_complex():
230230
c.SYS.Ping.Rsp(partial=True),
231231
c.SYS.Ping.Rsp(partial=True),
232232
# Matching against different command types should also work
233-
c.Util.TimeAlive.Rsp(Seconds=12),
234-
c.Util.TimeAlive.Rsp(Seconds=10),
233+
c.UTIL.TimeAlive.Rsp(Seconds=12),
234+
c.UTIL.TimeAlive.Rsp(Seconds=10),
235235
c.AppConfig.BDBCommissioningNotification.Callback(
236236
partial=True, Status=c.app_config.BDBCommissioningStatus.InProgress
237237
),
@@ -255,8 +255,8 @@ async def test_command_deduplication_complex():
255255

256256
assert set(result) == {
257257
c.SYS.Ping.Rsp(partial=True),
258-
c.Util.TimeAlive.Rsp(Seconds=12),
259-
c.Util.TimeAlive.Rsp(Seconds=10),
258+
c.UTIL.TimeAlive.Rsp(Seconds=12),
259+
c.UTIL.TimeAlive.Rsp(Seconds=10),
260260
c.AppConfig.BDBCommissioningNotification.Callback(
261261
partial=True, Status=c.app_config.BDBCommissioningStatus.InProgress
262262
),
@@ -285,7 +285,7 @@ async def async_callback(response):
285285

286286
good_response1 = c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS)
287287
good_response2 = c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.APP)
288-
good_response3 = c.Util.TimeAlive.Rsp(Seconds=12)
288+
good_response3 = c.UTIL.TimeAlive.Rsp(Seconds=12)
289289
bad_response1 = c.SYS.SetExtAddr.Rsp(Status=t.Status.SUCCESS)
290290
bad_response2 = c.SYS.NVWrite.Req(
291291
SysId=0x12, ItemId=0x3456, SubId=0x7890, Offset=0x00, Value=b"asdfoo"
@@ -296,16 +296,16 @@ async def async_callback(response):
296296
c.SYS.Ping.Rsp(partial=True),
297297
c.SYS.Ping.Rsp(partial=True),
298298
# Matching against different response types should also work
299-
c.Util.TimeAlive.Rsp(Seconds=12),
299+
c.UTIL.TimeAlive.Rsp(Seconds=12),
300300
c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS),
301301
c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS),
302-
c.Util.TimeAlive.Rsp(Seconds=10),
302+
c.UTIL.TimeAlive.Rsp(Seconds=10),
303303
]
304304

305305
assert set(_deduplicate_commands(responses)) == {
306306
c.SYS.Ping.Rsp(partial=True),
307-
c.Util.TimeAlive.Rsp(Seconds=12),
308-
c.Util.TimeAlive.Rsp(Seconds=10),
307+
c.UTIL.TimeAlive.Rsp(Seconds=12),
308+
c.UTIL.TimeAlive.Rsp(Seconds=10),
309309
}
310310

311311
# We shouldn't see any effects from receiving a frame early
@@ -335,7 +335,7 @@ async def test_wait_for_responses(connected_znp, event_loop):
335335

336336
response1 = c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS)
337337
response2 = c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.APP)
338-
response3 = c.Util.TimeAlive.Rsp(Seconds=12)
338+
response3 = c.UTIL.TimeAlive.Rsp(Seconds=12)
339339
response4 = c.SYS.SetExtAddr.Rsp(Status=t.Status.SUCCESS)
340340
response5 = c.SYS.NVWrite.Req(
341341
SysId=0x12, ItemId=0x3456, SubId=0x7890, Offset=0x00, Value=b"asdfoo"
@@ -352,22 +352,22 @@ async def test_wait_for_responses(connected_znp, event_loop):
352352
# Will match the first response3 and detach
353353
future2 = znp.wait_for_responses(
354354
[
355-
c.Util.TimeAlive.Rsp(Seconds=12),
355+
c.UTIL.TimeAlive.Rsp(Seconds=12),
356356
c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.UTIL),
357357
]
358358
)
359359

360360
# Will not match anything
361-
future3 = znp.wait_for_responses([c.Util.TimeAlive.Rsp(Seconds=10)])
361+
future3 = znp.wait_for_responses([c.UTIL.TimeAlive.Rsp(Seconds=10)])
362362

363363
# Will match response1 the second time around
364364
future4 = znp.wait_for_responses(
365365
[
366366
# Matching against different response types should also work
367-
c.Util.TimeAlive.Rsp(Seconds=12),
367+
c.UTIL.TimeAlive.Rsp(Seconds=12),
368368
c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS),
369369
c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS),
370-
c.Util.TimeAlive.Rsp(Seconds=10),
370+
c.UTIL.TimeAlive.Rsp(Seconds=10),
371371
]
372372
)
373373

@@ -401,6 +401,6 @@ async def test_wait_for_responses(connected_znp, event_loop):
401401

402402
await asyncio.sleep(0)
403403

404-
znp.frame_received(c.Util.TimeAlive.Rsp(Seconds=10).to_frame())
404+
znp.frame_received(c.UTIL.TimeAlive.Rsp(Seconds=10).to_frame())
405405
assert future3.done()
406-
assert (await future3) == c.Util.TimeAlive.Rsp(Seconds=10)
406+
assert (await future3) == c.UTIL.TimeAlive.Rsp(Seconds=10)

tests/application/test_requests.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,12 @@ def assoc_get_with_addr(req):
777777

778778
if assoc_device is None:
779779
dev, _ = c.util.Device.deserialize(b"\xFF" * 100)
780-
return c.Util.AssocGetWithAddress.Rsp(Device=dev)
780+
return c.UTIL.AssocGetWithAddress.Rsp(Device=dev)
781781

782-
return c.Util.AssocGetWithAddress.Rsp(Device=assoc_device)
782+
return c.UTIL.AssocGetWithAddress.Rsp(Device=assoc_device)
783783

784784
did_assoc_get = znp_server.reply_once_to(
785-
c.Util.AssocGetWithAddress.Req(IEEE=device.ieee, partial=True),
785+
c.UTIL.AssocGetWithAddress.Req(IEEE=device.ieee, partial=True),
786786
responses=[assoc_get_with_addr],
787787
)
788788

@@ -796,23 +796,23 @@ def assoc_remove(req):
796796
nonlocal assoc_device
797797

798798
if assoc_device is None:
799-
return c.Util.AssocRemove.Rsp(Status=t.Status.FAILURE)
799+
return c.UTIL.AssocRemove.Rsp(Status=t.Status.FAILURE)
800800

801801
assoc_device = None
802-
return c.Util.AssocRemove.Rsp(Status=t.Status.SUCCESS)
802+
return c.UTIL.AssocRemove.Rsp(Status=t.Status.SUCCESS)
803803

804804
did_assoc_remove = znp_server.reply_once_to(
805-
c.Util.AssocRemove.Req(IEEE=device.ieee),
805+
c.UTIL.AssocRemove.Req(IEEE=device.ieee),
806806
responses=[assoc_remove],
807807
)
808808

809809
did_assoc_add = znp_server.reply_once_to(
810-
c.Util.AssocAdd.Req(
810+
c.UTIL.AssocAdd.Req(
811811
NWK=device.nwk,
812812
IEEE=device.ieee,
813813
NodeRelation=c.util.NodeRelation.CHILD_FFD_RX_IDLE,
814814
),
815-
responses=[c.Util.AssocAdd.Rsp(Status=t.Status.SUCCESS)],
815+
responses=[c.UTIL.AssocAdd.Rsp(Status=t.Status.SUCCESS)],
816816
)
817817
else:
818818
did_assoc_remove = None

tests/application/test_startup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ async def test_led_mode(device, make_application):
175175
# Z-Stack just does not respond to this command if HAL_LED is not enabled
176176
# It does not send the usual "command not recognized" response
177177
set_led_mode = znp_server.reply_once_to(
178-
request=c.Util.LEDControl.Req(partial=True),
178+
request=c.UTIL.LEDControl.Req(partial=True),
179179
responses=[]
180180
if device is FormedLaunchpadCC26X2R1
181-
else [c.Util.LEDControl.Rsp(Status=t.Status.SUCCESS)],
181+
else [c.UTIL.LEDControl.Rsp(Status=t.Status.SUCCESS)],
182182
)
183183

184184
await app.startup(auto_form=False)

tests/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,14 @@ def reset_req(self, request, *, startup=True):
637637
MaintRel=version.MaintRel,
638638
)
639639

640-
@reply_to(c.Util.GetDeviceInfo.Req())
640+
@reply_to(c.UTIL.GetDeviceInfo.Req())
641641
def util_device_info(self, request):
642642
nwk = 0xFFFE
643643

644644
if self.device_state == t.DeviceState.StartedAsCoordinator:
645645
nwk = 0x0000
646646

647-
return c.Util.GetDeviceInfo.Rsp(
647+
return c.UTIL.GetDeviceInfo.Rsp(
648648
Status=t.Status.SUCCESS,
649649
IEEE=t.EUI64.deserialize(self._nvram[ExNvIds.LEGACY][OsalNvIds.EXTADDR])[0],
650650
NWK=nwk,
@@ -801,7 +801,7 @@ def permit_join(self, request):
801801
c.ZDO.PermitJoinInd.Callback(Duration=0),
802802
]
803803

804-
@reply_to(c.Util.LEDControl.Req(partial=True))
804+
@reply_to(c.UTIL.LEDControl.Req(partial=True))
805805
def led_responder(self, req):
806806
return req.Rsp(Status=t.Status.SUCCESS)
807807

@@ -1030,7 +1030,7 @@ def node_desc_responder(self, req):
10301030
),
10311031
]
10321032

1033-
@reply_to(c.Util.LEDControl.Req(partial=True))
1033+
@reply_to(c.UTIL.LEDControl.Req(partial=True))
10341034
def led_responder(self, req):
10351035
# XXX: Yes, there is *no response*
10361036
return
@@ -1076,7 +1076,7 @@ def version_replier(self, request):
10761076

10771077
node_desc_responder = BaseZStack1CC2531.node_desc_responder
10781078

1079-
@reply_to(c.Util.LEDControl.Req(partial=True))
1079+
@reply_to(c.UTIL.LEDControl.Req(partial=True))
10801080
def led_responder(self, req):
10811081
return req.Rsp(Status=t.Status.SUCCESS)
10821082

tests/test_commands.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,23 @@ def test_command_param_binding():
184184

185185
# Invalid type
186186
with pytest.raises(ValueError):
187-
c.Util.TimeAlive.Rsp(Seconds=b"asd")
187+
c.UTIL.TimeAlive.Rsp(Seconds=b"asd")
188188

189189
# Valid type but invalid value
190190
with pytest.raises(ValueError):
191-
c.Util.SetPreConfigKey.Req(PreConfigKey=t.KeyData([1, 2, 3]))
191+
c.UTIL.SetPreConfigKey.Req(PreConfigKey=t.KeyData([1, 2, 3]))
192192

193193
# Coerced numerical type
194-
a = c.Util.TimeAlive.Rsp(Seconds=12)
195-
b = c.Util.TimeAlive.Rsp(Seconds=t.uint32_t(12))
194+
a = c.UTIL.TimeAlive.Rsp(Seconds=12)
195+
b = c.UTIL.TimeAlive.Rsp(Seconds=t.uint32_t(12))
196196

197197
assert a == b
198198
assert a.Seconds == b.Seconds
199199
assert type(a.Seconds) == type(b.Seconds) == t.uint32_t # noqa: E721
200200

201201
# Overflowing integer types
202202
with pytest.raises(ValueError):
203-
c.Util.TimeAlive.Rsp(Seconds=10 ** 20)
203+
c.UTIL.TimeAlive.Rsp(Seconds=10 ** 20)
204204

205205
# Integers will not be coerced to enums
206206
assert t.MTCapabilities.SYS == 0x0001
@@ -223,15 +223,15 @@ def test_command_param_binding():
223223
assert isinstance(cmd.Value, t.ShortBytes)
224224

225225
# Lists are converted to typed LVLists
226-
c.Util.BindAddEntry.Req(
226+
c.UTIL.BindAddEntry.Req(
227227
DstAddrModeAddr=t.AddrModeAddress(mode=t.AddrMode.NWK, address=0x1234),
228228
DstEndpoint=0x56,
229229
ClusterIdList=[0x12, 0x45],
230230
)
231231

232232
# Type errors within containers are also caught
233233
with pytest.raises(ValueError):
234-
c.Util.BindAddEntry.Req(
234+
c.UTIL.BindAddEntry.Req(
235235
DstAddrModeAddr=t.AddrModeAddress(mode=t.AddrMode.NWK, address=0x1234),
236236
DstEndpoint=0x56,
237237
ClusterIdList=[0x12, 0x457890], # 0x457890 doesn't fit into a uint8_t
@@ -372,7 +372,7 @@ def test_simple_descriptor():
372372

373373

374374
def test_command_str_repr():
375-
command = c.Util.BindAddEntry.Req(
375+
command = c.UTIL.BindAddEntry.Req(
376376
DstAddrModeAddr=t.AddrModeAddress(mode=t.AddrMode.NWK, address=0x1234),
377377
DstEndpoint=0x56,
378378
ClusterIdList=[0x12, 0x34],

zigpy_znp/commands/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
from .af import AF
2-
from .app import App
2+
from .app import APP
33
from .mac import MAC
44
from .sys import SYS
55
from .ubl import UBL
66
from .zdo import ZDO
77
from .zgp import ZGP
88
from .znp import ZNP
99
from .sapi import SAPI
10-
from .util import Util
10+
from .util import UTIL
1111
from .rpc_error import RPCError
1212
from .app_config import AppConfig
1313

1414
ALL_COMMANDS = [
1515
RPCError,
1616
AF,
17-
App,
17+
APP,
1818
AppConfig,
1919
MAC,
2020
SAPI,
2121
SYS,
22-
Util,
22+
UTIL,
2323
ZDO,
2424
ZGP,
2525
ZNP,

zigpy_znp/commands/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import zigpy_znp.types as t
22

33

4-
class App(t.CommandsBase, subsystem=t.Subsystem.APP):
4+
class APP(t.CommandsBase, subsystem=t.Subsystem.APP):
55
# This command is sent to the target in order to test the functions defined
66
# for individual applications.
77
# This command sends a raw data to an application

zigpy_znp/commands/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LEDMode(t.enum_uint8):
6969
TOGGLE = 4
7070

7171

72-
class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
72+
class UTIL(t.CommandsBase, subsystem=t.Subsystem.UTIL):
7373
# MAC Reset command to reset MAC state machine
7474
GetDeviceInfo = t.CommandDef(
7575
t.CommandType.SREQ,

0 commit comments

Comments
 (0)