Beispiel #1
0
 def test_read_with_invalid_page_error(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         bytearray(range(1)),
     ]
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.read(0)
     assert excinfo.value.errno == nfc.tag.tt2.INVALID_PAGE_ERROR
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
Beispiel #2
0
 def test_read_with_invalid_page_error(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         bytearray(range(1)),
     ]
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.read(0)
     assert excinfo.value.errno == nfc.tag.tt2.INVALID_PAGE_ERROR
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
Beispiel #3
0
 def test_read_with_receive_error(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         bytearray(range(1)),
     ]
     tag.clf.sense.return_value = None
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.read(0)
     assert excinfo.value.errno == nfc.tag.RECEIVE_ERROR
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
Beispiel #4
0
 def test_read_with_receive_error(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         bytearray(range(1)),
     ]
     tag.clf.sense.return_value = None
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.read(0)
     assert excinfo.value.errno == nfc.tag.RECEIVE_ERROR
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
Beispiel #5
0
 def test_read_with_page_number(self, tag, page):
     commands = [
         (HEX('30 %02x' % (page % 256)), 0.005),
     ]
     responses = [
         bytearray(range(16)),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.read(page) == bytearray(range(16))
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
Beispiel #6
0
 def test_read_with_page_number(self, tag, page):
     commands = [
         (HEX('30 %02x' % (page % 256)), 0.005),
     ]
     responses = [
         bytearray(range(16)),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.read(page) == bytearray(range(16))
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]