def tco(self): tco = nfc.llcp.tco.LogicalDataLink(128) assert tco.state.ESTABLISHED is True assert tco.bind(1) == 1 yield tco tco.close() assert tco.state.SHUTDOWN is True
def test_connect_by_addr_or_name(self, tco, dest, dsap): pdu = nfc.llcp.pdu.ConnectionComplete(tco.addr, dsap, 1000, 2) threading.Timer(0.01, tco.enqueue, (pdu, )).start() tco.connect(dest) assert tco.state.ESTABLISHED is True pdu = nfc.llcp.pdu.DisconnectedMode(tco.addr, dsap) threading.Timer(0.01, tco.enqueue, (pdu, )).start() tco.close() assert tco.state.SHUTDOWN is True
def test_connect_by_addr_or_name(self, tco, dest, dsap): pdu = nfc.llcp.pdu.ConnectionComplete(tco.addr, dsap, 1000, 2) threading.Timer(0.01, tco.enqueue, (pdu,)).start() tco.connect(dest) assert tco.state.ESTABLISHED is True pdu = nfc.llcp.pdu.DisconnectedMode(tco.addr, dsap) threading.Timer(0.01, tco.enqueue, (pdu,)).start() tco.close() assert tco.state.SHUTDOWN is True
def test_send(self, tco): pdu = nfc.llcp.pdu.UnnumberedInformation(1, 1, HEX('1122')) assert tco.send(pdu, flags=nfc.llcp.MSG_DONTWAIT) is True assert tco.dequeue(10, 4) == pdu threading.Timer(0.01, tco.dequeue, (10, 4)).start() assert tco.send(pdu, 0) is True tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.send(pdu, 0) assert excinfo.value.errno == errno.ESHUTDOWN
def test_listen(self, tco): tco.listen(backlog=1) assert tco.state.LISTEN is True with pytest.raises(nfc.llcp.Error) as excinfo: tco.listen(1) assert excinfo.value.errno == errno.ENOTSUP tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.listen(1) assert excinfo.value.errno == errno.ESHUTDOWN
def test_poll(self, tco): assert tco.poll("recv", 0.001) is False assert tco.poll("send", 0.001) is True with pytest.raises(nfc.llcp.Error) as excinfo: tco.poll("invalid", 1) assert excinfo.value.errno == errno.EINVAL tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.poll("recv", 1) assert excinfo.value.errno == errno.ESHUTDOWN
def test_sockopt(self, tco): assert tco.getsockopt(nfc.llcp.SO_RCVBUF) == 1 tco.setsockopt(nfc.llcp.SO_RCVBUF, 2) assert tco.getsockopt(nfc.llcp.SO_RCVBUF) == 2 tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.setsockopt(nfc.llcp.SO_RCVBUF, 2) assert excinfo.value.errno == errno.ESHUTDOWN with pytest.raises(nfc.llcp.Error) as excinfo: tco.getsockopt(nfc.llcp.SO_RCVBUF) assert excinfo.value.errno == errno.ESHUTDOWN
def test_sendto(self, tco): pdu = nfc.llcp.pdu.UnnumberedInformation(1, 1, HEX('1122')) assert tco.sendto(pdu.data, 1, flags=nfc.llcp.MSG_DONTWAIT) is True assert tco.dequeue(10, 4) == pdu assert tco.connect(2) is True with pytest.raises(nfc.llcp.Error) as excinfo: tco.sendto(pdu.data, 1, flags=nfc.llcp.MSG_DONTWAIT) assert excinfo.value.errno == errno.EDESTADDRREQ with pytest.raises(nfc.llcp.Error) as excinfo: data = (tco.send_miu + 1) * HEX('11') tco.sendto(data, 2, flags=nfc.llcp.MSG_DONTWAIT) assert excinfo.value.errno == errno.EMSGSIZE tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.sendto(pdu.data, 1, 0) assert excinfo.value.errno == errno.ESHUTDOWN
def tco(self): tco = nfc.llcp.tco.RawAccessPoint(128) assert tco.state.ESTABLISHED is True yield tco tco.close() assert tco.state.SHUTDOWN is True
def test_connect(self, tco): assert tco.connect(1) == 1 tco.close() with pytest.raises(nfc.llcp.Error) as excinfo: tco.connect(2) assert excinfo.value.errno == errno.ESHUTDOWN
def tco(self): tco = nfc.llcp.tco.TransmissionControlObject(10, 10) yield tco tco.close() assert tco.state.SHUTDOWN is True