def test_decode(tnefspec): fn, key, attchs, body, objs = tnefspec with open(datadir + os.sep + fn, "rb") as tfile: t = TNEF(tfile.read()) assert t.key == key, "wrong key: 0x%2.2x" % t.key for m in t.mapiprops: assert m.__str__() assert m.data is not None for i, a in enumerate(t.attachments): assert a.long_filename() == attchs[i] for m in a.mapi_attrs: assert m.__str__() assert m.data is not None for m in t.msgprops: assert m.__str__() assert m.data is not None if m.name == TNEF.ATTRECIPTABLE: for n_m in m.data[0]: assert isinstance(n_m, TNEFMAPI_Attribute) if t.htmlbody: assert 'html' in t.htmlbody if body: assert getattr(t, body) assert t.has_body() else: assert not t.has_body() if t.rtfbody: assert t.rtfbody[0:5] == b'{\\rtf' if objs: assert objcodes(t) == objs, "wrong objs: %s" % [ "0x%2.2x" % o.name for o in t.objects ] assert t.dump(True) assert t.dump(False)
def test_decode(tnefspec): fn, key, attchs, body, objs = tnefspec t = TNEF((DATADIR / fn).read_bytes()) assert t.key == key, f"wrong key: 0x{t.key:2.2x}" for m in t.mapiprops: assert m.__str__() assert m.data is not None for i, a in enumerate(t.attachments): assert a.long_filename() == attchs[i] assert type(a.data) is bytes for m in a.mapi_attrs: assert m.__str__() assert m.data is not None for m in t.msgprops: assert m.__str__() assert m.data is not None if m.name == TNEF.ATTRECIPTABLE: for n_m in m.data[0]: assert isinstance(n_m, TNEFMAPI_Attribute) if t.htmlbody: assert 'html' in t.htmlbody if body: assert getattr(t, body) assert t.has_body() else: assert not t.has_body() if t.rtfbody: assert t.rtfbody[0:5] == b'{\\rtf' if objs: assert objcodes(t) == objs, "wrong objs: " + str([f"0x{o.name:2.2x}" for o in t.objects]) assert t.dump(True) assert t.dump(False)
def test_decode(tnefspec): fn, key, attchs, body, objs = tnefspec with open(datadir + os.sep + fn, "rb") as tfile: t = TNEF(tfile.read()) assert t.key == key, "wrong key: 0x%2.2x" % t.key for m in t.mapiprops: assert m.__str__() assert m.data is not None for i, a in enumerate(t.attachments): assert a.long_filename() == attchs[i] for m in a.mapi_attrs: assert m.__str__() assert m.data is not None for m in t.msgprops: assert m.__str__() assert m.data is not None if m.name == TNEF.ATTRECIPTABLE: for n_m in m.data[0]: assert isinstance(n_m, TNEFMAPI_Attribute) if t.htmlbody: assert 'html' in t.htmlbody if body: assert getattr(t, body) assert t.has_body() else: assert not t.has_body() if t.rtfbody: assert t.rtfbody[0:5] == b'{\\rtf' if objs: assert objcodes(t) == objs, "wrong objs: %s" % ["0x%2.2x" % o.name for o in t.objects] assert t.dump(True) assert t.dump(False)