|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import TYPE_CHECKING |
| 5 | +import pytest |
6 | 6 |
|
7 | 7 | from schnee.adapters.backend import PcscBackend |
8 | 8 | from schnee.adapters.backend.pcsc import PcscReaderProvider |
9 | 9 | from schnee.adapters.ntag.apdu import CommandAPDU |
10 | 10 |
|
11 | | -if TYPE_CHECKING: |
12 | | - import pytest |
13 | | - |
14 | 11 |
|
15 | 12 | class FakeConnection: |
16 | 13 | """Fake PC/SC connection.""" |
@@ -44,19 +41,27 @@ def create_connection(self) -> FakeConnection: |
44 | 41 | return self.connection |
45 | 42 |
|
46 | 43 |
|
47 | | -def test_pcsc_backend_wraps_reader_and_reads_profile_uid() -> None: |
48 | | - """PC/SC backend reads a profile through the wrapped reader.""" |
| 44 | +def test_pcsc_backend_reads_tag_info_uid() -> None: |
| 45 | + """PC/SC backend reads tag identity through the wrapped reader.""" |
49 | 46 | reader = FakeReader() |
50 | 47 | backend = PcscBackend(reader=reader) |
51 | 48 |
|
52 | | - profile = backend.read_profile() |
| 49 | + tag = backend.read_tag_info() |
53 | 50 |
|
54 | 51 | assert backend.reader_name == "Fake PCSC Reader" |
55 | | - assert profile.tag.uid == "04112233445566" |
56 | | - assert profile.tag.features == ["pcsc"] |
| 52 | + assert tag.uid == "04112233445566" |
| 53 | + assert tag.features == ["pcsc"] |
57 | 54 | assert reader.connection.commands == [[0xFF, 0xCA, 0x00, 0x00, 0x00]] |
58 | 55 |
|
59 | 56 |
|
| 57 | +def test_pcsc_backend_rejects_full_profile_reads() -> None: |
| 58 | + """PC/SC backend does not fabricate full profile data from UID-only reads.""" |
| 59 | + backend = PcscBackend(reader=FakeReader()) |
| 60 | + |
| 61 | + with pytest.raises(PcscBackend.UnsupportedProfileReadError): |
| 62 | + backend.read_profile() |
| 63 | + |
| 64 | + |
60 | 65 | def test_pcsc_backend_sends_command_apdu() -> None: |
61 | 66 | """PC/SC backend accepts CommandAPDU objects.""" |
62 | 67 | reader = FakeReader() |
|
0 commit comments