Esempio n. 1
0
def test_multipart_minimal():
    msg = _parse('multimin')
    tree = walk.get_tree(msg)

    assert tree['multi'] is True
    assert len(tree['part_map']) == 1
    first = tree['part_map'][1]
    assert first['multi'] is False
    assert first['ctype'] == 'text/plain'
Esempio n. 2
0
def test_multi_signed():
    msg = _parse('multisigned')
    tree = walk.get_tree(msg)
    assert tree['multi'] is True
    assert len(tree['part_map']) == 2

    _first = tree['part_map'][1]
    _second = tree['part_map'][2]
    assert len(_first['part_map']) == 3
    assert (_second['multi'] is False)
Esempio n. 3
0
def test_bounce_mime():
    msg = _parse('bounced')
    tree = walk.get_tree(msg)

    ctypes = [
        tree['part_map'][index]['ctype']
        for index in sorted(tree['part_map'].keys())
    ]
    third = tree['part_map'][3]
    three_one_ctype = third['part_map'][1]['ctype']
    assert three_one_ctype == 'multipart/signed'

    assert ctypes == [
        'text/plain', 'message/delivery-status', 'message/rfc822'
    ]
Esempio n. 4
0
def _split_into_parts(raw):
    # TODO signal that we can delete the original message!-----
    # when all the processing is done.
    # TODO add the linked-from info !
    # TODO add reference to the original message?
    # TODO populate Default FLAGS/TAGS (unseen?)
    # TODO seed propely the content_docs with defaults??

    msg, chash, multi = _parse_msg(raw)
    size = len(msg.as_string())

    parts_map = walk.get_tree(msg)
    cdocs_list = list(walk.get_raw_docs(msg))
    cdocs_phashes = [c['phash'] for c in cdocs_list]
    body_phash = walk.get_body_phash(msg)

    mdoc = _build_meta_doc(chash, cdocs_phashes)
    fdoc = _build_flags_doc(chash, size, multi)
    hdoc = _build_headers_doc(msg, chash, body_phash, parts_map)

    # The MessageWrapper expects a dict, one-indexed
    cdocs = dict(enumerate(cdocs_list, 1))

    return mdoc, fdoc, hdoc, cdocs
Esempio n. 5
0
def test_simple_mail():
    msg = _parse('simple')
    tree = walk.get_tree(msg)
    assert len(tree['part_map']) == 0
    assert tree['ctype'] == 'text/plain'
    assert tree['multi'] is False