コード例 #1
0
ファイル: test_record.py プロジェクト: ozliver/ndeflib
 def test_limit(self):
     stream = BytesIO()
     record = Record('unknown', '', 0x100000 * b'\0')
     octets = bytearray.fromhex('050000100000') + 0x100000 * b'\0'
     assert record._encode(stream=stream) == len(octets)
     assert stream.getvalue() == octets
     record = Record('unknown', '', 0x100001 * b'\0')
     errstr = "payload of more than 1048576 octets can not be encoded"
     with pytest.raises(ndef.EncodeError) as excinfo:
         record._encode(stream=stream)
     assert str(excinfo.value) == 'ndef.record.Record ' + errstr
コード例 #2
0
ファイル: test_record.py プロジェクト: nfcpy/ndeflib
 def test_limit(self):
     stream = BytesIO()
     record = Record('unknown', '', 0x100000 * b'\0')
     octets = bytearray.fromhex('050000100000') + 0x100000 * b'\0'
     assert record._encode(stream=stream) == len(octets)
     assert stream.getvalue() == octets
     record = Record('unknown', '', 0x100001 * b'\0')
     errstr = "payload of more than 1048576 octets can not be encoded"
     with pytest.raises(ndef.EncodeError) as excinfo:
         record._encode(stream=stream)
     assert str(excinfo.value) == 'ndef.record.Record ' + errstr
コード例 #3
0
ファイル: test_record.py プロジェクト: ozliver/ndeflib
 def test_pass(self, args, encoded):
     stream = BytesIO()
     record = Record(*args)
     octets = bytearray.fromhex(encoded)
     assert record._encode(stream=stream) == len(octets)
     assert stream.getvalue() == octets
コード例 #4
0
ファイル: test_record.py プロジェクト: nfcpy/ndeflib
 def test_pass(self, args, encoded):
     stream = BytesIO()
     record = Record(*args)
     octets = bytearray.fromhex(encoded)
     assert record._encode(stream=stream) == len(octets)
     assert stream.getvalue() == octets