Example #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)
Example #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)
Example #3
0
 def test_recvfrom_with_invalid_tco_object(self, llc):
     sock = nfc.llcp.tco.TransmissionControlObject(0, 0)
     sock.addr = 1
     llc.recvfrom(sock)
Example #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)
Example #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)
Example #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
Example #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
Example #8
0
 def test_recvfrom_with_invalid_tco_object(self, llc):
     sock = nfc.llcp.tco.TransmissionControlObject(0, 0)
     sock.addr = 1
     llc.recvfrom(sock)
Example #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)
Example #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)
Example #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
Example #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