示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 def test_recvfrom_with_invalid_tco_object(self, llc):
     sock = nfc.llcp.tco.TransmissionControlObject(0, 0)
     sock.addr = 1
     llc.recvfrom(sock)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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
示例#7
0
 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
示例#8
0
 def test_recvfrom_with_invalid_tco_object(self, llc):
     sock = nfc.llcp.tco.TransmissionControlObject(0, 0)
     sock.addr = 1
     llc.recvfrom(sock)
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 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
示例#12
0
 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