import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.hf_15 import HF15Commands

def test_15_scan():
    t = AsyncMock()
    iso15 = HF15Commands(t)
    # Fake response: flags(1) + DSFID(1) + UID(8)
    resp_data = bytes([0x00, 0x00]) + bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xE0])
    t.send_ng.return_value = PM3Response(cmd=Cmd.HF_ISO15693_COMMAND, status=0,
                                          reason=0, ng=True, data=resp_data)
    result = asyncio.get_event_loop().run_until_complete(iso15.scan())
    assert "uid" in result
