コード例 #1
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_write_with_invalid_page_error(self, tag):
     commands = [
         (HEX('a2 00 01020304'), 0.1),
     ]
     responses = [
         HEX('00'),
     ]
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.write(0, HEX('01020304'))
     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_write_with_invalid_page_error(self, tag):
     commands = [
         (HEX('a2 00 01020304'), 0.1),
     ]
     responses = [
         HEX('00'),
     ]
     tag.clf.exchange.side_effect = responses
     with pytest.raises(nfc.tag.tt2.Type2TagCommandError) as excinfo:
         tag.write(0, HEX('01020304'))
     assert excinfo.value.errno == nfc.tag.tt2.INVALID_PAGE_ERROR
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
コード例 #3
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_write_with_page_and_data(self, tag, page, data):
     commands = [
         (HEX('a2 %02x %s' % (page % 256, data)), 0.1),
     ]
     responses = [
         HEX('0a'),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.write(page, HEX(data)) is True
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
コード例 #4
0
ファイル: test_tag_tt2.py プロジェクト: nfcpy/nfcpy
 def test_write_with_page_and_data(self, tag, page, data):
     commands = [
         (HEX('a2 %02x %s' % (page % 256, data)), 0.1),
     ]
     responses = [
         HEX('0a'),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.write(page, HEX(data)) is True
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
コード例 #5
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_write_with_invalid_data(self, tag, data):
     with pytest.raises(ValueError) as excinfo:
         tag.write(0, HEX(data))
     assert str(excinfo.value) == "data must be a four byte string or array"
コード例 #6
0
ファイル: test_tag_tt2.py プロジェクト: nfcpy/nfcpy
 def test_write_with_invalid_data(self, tag, data):
     with pytest.raises(ValueError) as excinfo:
         tag.write(0, HEX(data))
     assert str(excinfo.value) == "data must be a four byte string or array"