Esempio n. 1
0
 def test_run_with_sec_error(self, llc, error):
     llc.mac.exchange.side_effect = [error]
     with pytest.raises(SystemExit):
         llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
     ]
Esempio n. 2
0
 def test_run_with_remote_terminate(self, llc):
     llc.mac.exchange.side_effect = [HEX('0000'), HEX('0140')]
     llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0000'), 0.11),
     ]
Esempio n. 3
0
 def test_run_with_sec_error(self, llc, error):
     llc.mac.exchange.side_effect = [error]
     with pytest.raises(SystemExit):
         llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
     ]
Esempio n. 4
0
 def test_run_with_remote_terminate(self, llc):
     llc.mac.exchange.side_effect = [HEX('0000'), HEX('0140')]
     llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0000'), 0.11),
     ]
Esempio n. 5
0
 def test_run_send_pdu_and_symm(self, llc, ldl):
     llc.mac.exchange.side_effect = 10 * [HEX('0000')] + [None]
     llc.sendto(ldl, b'123', 16, nfc.llcp.MSG_DONTWAIT)
     llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('40e0313233'), 0.11)
     ] + 10 * [mock.call(HEX('0000'), 0.11)]
     assert str(llc.pcnt) == "sent/rcvd 11/10 SYMM 10/10 UI 1/0"
Esempio n. 6
0
 def test_run_with_kbd_interrupt(self, llc):
     llc.mac.exchange.side_effect \
         = [HEX('0000'), KeyboardInterrupt, None]
     with pytest.raises(KeyboardInterrupt):
         llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0140'), 0.5),
     ]
Esempio n. 7
0
 def test_run_send_pdu_and_symm(self, llc, ldl):
     llc.mac.exchange.side_effect = 10 * [HEX('0000')] + [None]
     llc.sendto(ldl, b'123', 16, nfc.llcp.MSG_DONTWAIT)
     llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('40e0313233'), 0.11)
     ] + 10 * [
         mock.call(HEX('0000'), 0.11)
     ]
     assert str(llc.pcnt) == "sent/rcvd 11/10 SYMM 10/10 UI 1/0"
Esempio n. 8
0
 def test_run_with_kbd_interrupt(self, llc):
     llc.mac.exchange.side_effect \
         = [HEX('0000'), KeyboardInterrupt, None]
     with pytest.raises(KeyboardInterrupt):
         llc.run_as_initiator()
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0000'), 0.11),
         mock.call(HEX('0140'), 0.5),
     ]
Esempio n. 9
0
 def test_run_with_local_terminate(self, llc):
     llc.mac.exchange.side_effect = [HEX('01C0')]
     llc.run_as_initiator(terminate=lambda: True)
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0140'), 0.5),
     ]
Esempio n. 10
0
 def test_run_with_local_terminate(self, llc):
     llc.mac.exchange.side_effect = [HEX('01C0')]
     llc.run_as_initiator(terminate=lambda: True)
     assert llc.mac.exchange.mock_calls == [
         mock.call(HEX('0140'), 0.5),
     ]