Skip to content

Commit 2fe63ae

Browse files
Copilotbofh69
andauthored
[WIP] Improve API by standardizing protocols and memory access (#30)
* Initial plan * Fix failed unit test by adding missing mifare_authenticate mock Co-authored-by: bofh69 <1444315+bofh69@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bofh69 <1444315+bofh69@users.noreply.github.com>
1 parent 60aed6a commit 2fe63ae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_pn5180.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_connect_iso14443a(mock_interface_class: Mock) -> None:
190190

191191
@patch("pn5180_tagomatic.proxy.Interface")
192192
def test_card_read_memory(mock_interface_class: Mock) -> None:
193-
"""Test reading memory from non-MIFARE card."""
193+
"""Test reading memory from MIFARE Classic card using default keys."""
194194
tty = "/dev/ttyACM0"
195195
mock_interface = MagicMock()
196196
mock_interface_class.return_value = mock_interface
@@ -204,8 +204,9 @@ def test_card_read_memory(mock_interface_class: Mock) -> None:
204204
mock_interface.write_register.return_value = 0
205205
mock_interface.send_data.return_value = 0
206206
mock_interface.wait_for_irq.return_value = True
207+
mock_interface.mifare_authenticate.return_value = 0 # Success
207208

208-
# Mock UID retrieval (4-byte UID for simplicity)
209+
# Mock UID retrieval (4-byte UID for MIFARE Classic)
209210
mock_interface.read_register.side_effect = [
210211
(0, 0x0002), # ATQA
211212
(0, 0x0005), # UID (anticollision)
@@ -219,7 +220,7 @@ def test_card_read_memory(mock_interface_class: Mock) -> None:
219220
mock_interface.read_data.side_effect = [
220221
(0, [0x00, 0x00]), # ATQA (4-byte UID)
221222
(0, [0x01, 0x02, 0x03, 0x04, 0x04]), # UID + BCC (4-byte)
222-
(0, [0x08]), # SAK (bit 2 clear = complete)
223+
(0, [0x08]), # SAK (MIFARE Classic 1K)
223224
(0, [0xAA] * 16), # Memory page 0
224225
(0, [0xBB] * 16), # Memory page 4
225226
]

0 commit comments

Comments
 (0)