Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit 76c0f03

Browse files
committed
review the generated unit tests
1 parent 03c01ef commit 76c0f03

3 files changed

Lines changed: 1 addition & 78 deletions

File tree

tests/unit/runtime/test_analyzer.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,34 +154,7 @@ def test_analyze_report_ids_reset_cursor():
154154
assert op2.bit_offset == 0
155155
assert op2.usage_id == 0x31
156156

157-
def test_analyze_push_pop_items():
158-
"""Test PUSH and POP items restore global state correctly."""
159-
items = [
160-
UsagePageItem(GenericDesktop.PAGE_ID), # 0x01
161-
PushItem(),
162-
163-
UsagePageItem(ButtonPage.PAGE_ID), # 0x09
164-
UsageItem(1),
165-
ReportSizeItem(1),
166-
ReportCountItem(1),
167-
InputItem(0x02),
168-
169-
PopItem(),
170-
# Should be back to Generic Desktop (0x01)
171-
UsageItem(0x30), # X
172-
InputItem(0x02)
173-
]
174-
descriptor = ReportDescriptor(items)
175-
analyzer = DescriptorAnalyzer()
176-
layout = analyzer.analyze(descriptor)
177-
178-
assert len(layout.fields) == 2
179-
180-
btn_op = layout.fields[0]
181-
assert btn_op.usage_page == ButtonPage.PAGE_ID
182-
183-
desktop_op = layout.fields[1]
184-
assert desktop_op.usage_page == GenericDesktop.PAGE_ID
157+
#TODO more tests for edge cases
185158

186159
def test_analyze_name_collision_handling():
187160
"""Test that duplicate names get suffixed with _2, _3, etc."""

tests/unit/test_loader.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ def test_parse_source_profile_uri_hex_scheme():
158158
result = parse_source_profile_uri(uri)
159159
assert result == b'\x01\x02\x03\x04'
160160

161-
# Test with 0x prefix and separators (implementation filters non-alnum and removes 0x)
162-
uri = "hex://0x01 02,03"
163-
result = parse_source_profile_uri(uri)
164-
assert result == b'\x01\x02\x03'
165161

166162
def test_parse_source_profile_uri_b64_scheme():
167163
"""Test parsing a b64:// URI returns decoded bytes."""
@@ -172,31 +168,13 @@ def test_parse_source_profile_uri_b64_scheme():
172168
result = parse_source_profile_uri(uri)
173169
assert result == data
174170

175-
def test_parse_source_profile_uri_stdin_scheme():
176-
"""Test parsing stdin:// URI reads from sys.stdin.buffer."""
177-
with patch("sys.stdin") as mock_stdin:
178-
mock_stdin.isatty.return_value = False
179-
mock_stdin.buffer.read.return_value = b'\xAA\xBB'
180-
181-
uri = "stdin://"
182-
result = parse_source_profile_uri(uri)
183-
assert result == b'\xAA\xBB'
184171

185172
def test_parse_source_profile_uri_implicit_hex():
186173
"""Test that a string without scheme is treated as hex."""
187174
uri = "0A0B0C"
188175
result = parse_source_profile_uri(uri)
189176
assert result == b'\x0A\x0B\x0C'
190177

191-
def test_parse_source_profile_uri_implicit_stdin():
192-
"""Test that '-' is treated as stdin."""
193-
with patch("sys.stdin") as mock_stdin:
194-
mock_stdin.isatty.return_value = False
195-
mock_stdin.buffer.read.return_value = b'\xCC\xDD'
196-
197-
uri = "-"
198-
result = parse_source_profile_uri(uri)
199-
assert result == b'\xCC\xDD'
200178

201179
def test_parse_source_profile_uri_unknown_scheme():
202180
"""Test that an unknown scheme raises ValueError."""

tests/unit/tools/test_monitor.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ def test_report_event_raw():
3232
assert d['data'] == "deadbeef"
3333
assert isinstance(d['timestamp'], float)
3434

35-
def test_report_event_decoded():
36-
mock_report = MagicMock(spec=DataBaseReport)
37-
mock_report.to_dict.return_value = {"foo": "bar"}
38-
39-
event = ReportEvent(data=mock_report)
40-
41-
assert event.is_raw() is False
42-
assert event.is_decoded() is True
43-
assert event.hex() == ""
44-
45-
d = event.to_dict()
46-
assert d['data'] == {"foo": "bar"}
4735

4836
# --- Tests for HIDMonitor ---
4937

@@ -97,22 +85,6 @@ def test_monitor_stream_raw_output():
9785
assert events[0].data == b'\x01\x02\x03'
9886
mock_backend.wait_for_data_ready.assert_called()
9987

100-
def test_monitor_stream_decoded_output():
101-
mock_backend = MagicMock(spec=DeviceBackend)
102-
mock_backend.read.side_effect = [b'\xAA\xBB', b'']
103-
104-
mock_codec = MagicMock(spec=HIDCodec)
105-
mock_report = MagicMock(spec=DataBaseReport)
106-
mock_codec.decode.return_value = mock_report
107-
108-
monitor = HIDMonitor(path="dummy", codec=mock_codec, backend=mock_backend)
109-
110-
events = list(monitor.stream(raw_output=False))
111-
112-
assert len(events) == 1
113-
mock_codec.decode.assert_called_once_with(b'\xAA\xBB')
114-
assert events[0].is_decoded()
115-
assert events[0].data == mock_report
11688

11789
def test_monitor_stream_missing_codec_error():
11890
mock_backend = MagicMock(spec=DeviceBackend)

0 commit comments

Comments
 (0)