def test_recvfrom_with_dlc_socket(self, llc, dlc): pdu = nfc.llcp.pdu.ConnectionComplete(32, 17) threading.Timer(0.01, llc.collect).start() threading.Timer(0.02, llc.dispatch, (pdu,)).start() llc.connect(dlc, 17) pdu = nfc.llcp.pdu.Information(32, 17, 0, 0, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() assert llc.recvfrom(dlc) == (b'123', 17)
def test_recvfrom_with_dlc_socket(self, llc, dlc): pdu = nfc.llcp.pdu.ConnectionComplete(32, 17) threading.Timer(0.01, llc.collect).start() threading.Timer(0.02, llc.dispatch, (pdu,)).start() llc.connect(dlc, 17) pdu = nfc.llcp.pdu.Information(32, 17, 0, 0, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() assert llc.recvfrom(dlc) == (b'123', 17)
def test_recvfrom_with_invalid_tco_object(self, llc): sock = nfc.llcp.tco.TransmissionControlObject(0, 0) sock.addr = 1 llc.recvfrom(sock)
def test_recvfrom_with_ldl_socket(self, llc, ldl): pdu = nfc.llcp.pdu.UnnumberedInformation(32, 17, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() llc.bind(ldl, 32) assert llc.recvfrom(ldl) == (b'123', 17)
def test_recvfrom_with_raw_socket(self, llc, raw): pdu = nfc.llcp.pdu.UnnumberedInformation(32, 17, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() llc.bind(raw, 32) assert llc.recvfrom(raw) == (pdu, None)
def test_recvfrom_with_unbound_socket(self, llc, ldl): with pytest.raises(nfc.llcp.Error) as excinfo: llc.recvfrom(ldl) assert excinfo.value.errno == errno.EBADF
def test_recvfrom_with_invalid_socket_type(self, llc): with pytest.raises(nfc.llcp.Error) as excinfo: llc.recvfrom(object()) assert excinfo.value.errno == errno.ENOTSOCK
def test_recvfrom_with_invalid_tco_object(self, llc): sock = nfc.llcp.tco.TransmissionControlObject(0, 0) sock.addr = 1 llc.recvfrom(sock)
def test_recvfrom_with_ldl_socket(self, llc, ldl): pdu = nfc.llcp.pdu.UnnumberedInformation(32, 17, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() llc.bind(ldl, 32) assert llc.recvfrom(ldl) == (b'123', 17)
def test_recvfrom_with_raw_socket(self, llc, raw): pdu = nfc.llcp.pdu.UnnumberedInformation(32, 17, b'123') threading.Timer(0.01, llc.dispatch, (pdu,)).start() llc.bind(raw, 32) assert llc.recvfrom(raw) == (pdu, None)
def test_recvfrom_with_unbound_socket(self, llc, ldl): with pytest.raises(nfc.llcp.Error) as excinfo: llc.recvfrom(ldl) assert excinfo.value.errno == errno.EBADF
def test_recvfrom_with_invalid_socket_type(self, llc): with pytest.raises(nfc.llcp.Error) as excinfo: llc.recvfrom(object()) assert excinfo.value.errno == errno.ENOTSOCK