예제 #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]
예제 #2
0
파일: test_tag_tt2.py 프로젝트: nfcpy/nfcpy
 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]
예제 #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]
예제 #4
0
파일: test_tag_tt2.py 프로젝트: nfcpy/nfcpy
 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]
예제 #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]
예제 #6
0
파일: test_tag_tt2.py 프로젝트: nfcpy/nfcpy
 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]