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