Exemplo n.º 1
0
def test_new_ifd_entry_from_blob_with_offset(ifd_entry):
    entry = IfdEntry("<", blob=(b'\x00' + ifd_entry), offset=1, tags=tags)
    assert entry.tag_id == 271
    assert entry.tag_name == 'make'
    assert entry.tag_type == 's'
    assert entry.value_len == 6
    assert entry.raw_value == 232
Exemplo n.º 2
0
def test_new_ifd_entry_from_blob(ifd_entry):
    entry = IfdEntry("<", blob=ifd_entry, tags=tags)
    assert entry.tag_id == 271
    assert entry.tag_name == 'make'
    assert entry.tag_type == 's'
    assert entry.value_len == 6
    assert entry.raw_value == 232
Exemplo n.º 3
0
def test_new_ifd_entry_from_file(tmpdir, ifd_entry):
    p = tmpdir.realpath().strpath
    with open(os.path.join(p, 'ifd_entry'), mode='w+b') as tmpfile:
        tmpfile.write(ifd_entry)
        tmpfile.seek(0)
        entry = IfdEntry("<", file=tmpfile, tags=tags)
    assert entry.tag_id == 271
    assert entry.tag_name == 'make'
    assert entry.tag_type == 's'
    assert entry.value_len == 6
    assert entry.raw_value == 232
Exemplo n.º 4
0
def test_ifd_entry_short_value_seeks_to_end(entry_length_short_value):
    bytesio = BytesIO(entry_length_short_value)
    IfdEntry("<", file=bytesio, rewind=False)
    assert bytesio.tell() == 12
Exemplo n.º 5
0
def test_ifd_entry_no_offset_multi_value(entry_length_no_offset):
    entry = IfdEntry("<", blob=entry_length_no_offset)
    assert entry.raw_value == (46850, 768)
Exemplo n.º 6
0
def test_raw_value_not_offset(ifd_entry_not_offset):
    entry = IfdEntry("<", blob=ifd_entry_not_offset)
    assert entry.raw_value == 46848
Exemplo n.º 7
0
def test_unknown_tag_name_should_be_id(unknown_tag_ifd_entry):
    entry = IfdEntry("<", blob=unknown_tag_ifd_entry)
    assert entry.tag_name == 50885
Exemplo n.º 8
0
def test_new_ifd_no_offset(ifd_entry):
    with pytest.raises(KeyError):
        IfdEntry("<", blob=(b'\x00' + ifd_entry), tags=tags)
Exemplo n.º 9
0
def test_ifd_entry_must_have_single_data_source():
    with pytest.raises(TypeError):
        IfdEntry("<")
    with pytest.raises(TypeError):
        IfdEntry("<", blob=1, file=1, offset=1)