Esempio n. 1
0
def test_parse_msg_sender():
    sender, msg = d.parse_msg_sender(EML_MSG_FILENAME)
    # if the message in eml format
    with open(EML_MSG_FILENAME) as f:
        eq_(sender, " Alex Q <*****@*****.**>")
        eq_(msg, f.read())

    # if the message sender is stored in a separate file
    sender, msg = d.parse_msg_sender(MSG_FILENAME_WITH_BODY_SUFFIX)
    with open(MSG_FILENAME_WITH_BODY_SUFFIX) as f:
        eq_(sender, u"*****@*****.**")
        eq_(msg, f.read())
Esempio n. 2
0
def test_parse_msg_sender():
    sender, msg = d.parse_msg_sender(EML_MSG_FILENAME)
    # if the message in eml format
    with open(EML_MSG_FILENAME) as f:
        eq_(sender,
            " Alex Q <*****@*****.**>")
        eq_(msg, f.read())

    # if the message sender is stored in a separate file
    sender, msg = d.parse_msg_sender(MSG_FILENAME_WITH_BODY_SUFFIX)
    with open(MSG_FILENAME_WITH_BODY_SUFFIX) as f:
        eq_(sender, "*****@*****.**")
        eq_(msg, f.read())
Esempio n. 3
0
def test_messages_longer_SIGNATURE_MAX_LINES():
    for filename in os.listdir(STRIPPED):
        filename = os.path.join(STRIPPED, filename)
        if not filename.endswith('_body'):
            continue
        sender, body = dataset.parse_msg_sender(filename)
        text, extracted_signature = signature.extract(body, sender)
        extracted_signature = extracted_signature or ''
        with open(filename[:-len('body')] + 'signature') as ms:
            msg_signature = ms.read()
            eq_(msg_signature.strip(), extracted_signature.strip())
            stripped_msg = body.strip()[:len(body.strip())-len(msg_signature)]
            eq_(stripped_msg.strip(), text.strip())
Esempio n. 4
0
def test_messages_longer_SIGNATURE_MAX_LINES():
    for filename in os.listdir(STRIPPED):
        filename = os.path.join(STRIPPED, filename)
        if not filename.endswith('_body'):
            continue
        sender, body = dataset.parse_msg_sender(filename)
        text, extracted_signature = signature.extract(body, sender)
        extracted_signature = extracted_signature or ''
        with open(filename[:-len('body')] + 'signature') as ms:
            msg_signature = ms.read()
            eq_(msg_signature.strip(), extracted_signature.strip())
            stripped_msg = body.strip()[:len(body.strip())-len(msg_signature)]
            eq_(stripped_msg.strip(), text.strip())
Esempio n. 5
0
def test_messages_longer_SIGNATURE_MAX_LINES():
    import sys
    kwargs = {}
    if sys.version_info > (3, 0):
        kwargs["encoding"] = "utf8"

    for filename in os.listdir(STRIPPED):
        filename = os.path.join(STRIPPED, filename)
        if not filename.endswith('_body'):
            continue
        sender, body = dataset.parse_msg_sender(filename)
        text, extracted_signature = extract(body, sender)
        extracted_signature = extracted_signature or ''
        with open(filename[:-len('body')] + 'signature', **kwargs) as ms:
            msg_signature = ms.read()
            eq_(msg_signature.strip(), extracted_signature.strip())
            stripped_msg = body.strip()[:len(body.strip()) - len(msg_signature)]
            eq_(stripped_msg.strip(), text.strip())
Esempio n. 6
0
def test_handles_unicode():
    sender, body = dataset.parse_msg_sender(UNICODE_MSG)
    text, extracted_signature = signature.extract(body, sender)
Esempio n. 7
0
def test_handles_unicode():
    sender, body = dataset.parse_msg_sender(UNICODE_MSG)
    text, extracted_signature = extract(body, sender)