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), ]
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), ]
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"
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), ]
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"
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), ]