def test_get_messages():

    test_add_message()
    mlist = mailinglist.find_list(list_name)
    dbmessage = Message.objects.filter(mlist=mlist).all()[0]
    key = str(dbmessage.id)
    messages = archive.get_messages([key])
    assert len(messages) == 1
    rmessage = archive.get_message(key)
    assert json.dumps(rmessage, sort_keys=True) == archive.to_json(message.base)
def test_add_message():

    """
    Adds a message to the archive.
    """

    dbmessage = archive.store_message(list_name, message)

    assert dbmessage.subject == message['Subject']
    assert json.dumps(archive.get_message(str(dbmessage.id)), sort_keys=True) == archive.to_json(message.base)
Exemple #3
0
def test_to_json():
    msg = MailRequest('fakeperr', None, None, open("tests/bounce.msg").read())

    resp = mailinglist.craft_response(msg, 'test.list', '*****@*****.**')
    # attach an the message back but fake it as an image it'll be garbage
    resp.attach(filename="tests/bounce.msg", content_type="image/png", disposition="attachment")
    resp.to_message()  # prime the pump

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs['parts'][-1]['encoding']['format'] == 'base64'
def test_to_json():
    msg = MailRequest("fakeperr", None, None, open("tests/data/bounce.msg").read())

    resp = mailinglist.craft_response(msg, "test.list", "*****@*****.**")

    resp.attach(filename="tests/data/bounce.msg", content_type="image/png", disposition="attachment")
    resp.to_message()

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs["parts"][-1]["encoding"]["format"] == "base64"
Exemple #5
0
def convert_queue(arg, dirname, names):
    if dirname.endswith("new"):
        print dirname, names

        jpath = dirname + "/../../json"
        if not os.path.exists(jpath):
            os.mkdir(jpath)

        for key in names:
            json_file = key + ".json"
            json_archive = os.path.join(jpath, json_file)

            fpath = os.path.join(dirname, key)
            msg = MailRequest("librelist.com", None, None, open(fpath).read())
            f = open(json_archive, "w")
            f.write(archive.to_json(msg.base))
            f.close()
Exemple #6
0
def test_to_json():
    msg = MailRequest('fakeperr', None, None, open("tests/bounce.msg").read())

    resp = mailinglist.craft_response(msg, 'test.list',
                                      '*****@*****.**')
    # attach an the message back but fake it as an image it'll be garbage
    resp.attach(filename="tests/bounce.msg",
                content_type="image/png",
                disposition="attachment")
    resp.to_message()  # prime the pump

    js = archive.to_json(resp.base)
    assert js

    rtjs = json.loads(js)
    assert rtjs
    assert rtjs['parts'][-1]['encoding']['format'] == 'base64'
Exemple #7
0
def convert_queue(arg, dirname, names):
    if dirname.endswith("new"):
        print dirname, names

        jpath = dirname + "/../../json"
        if not os.path.exists(jpath):
            os.mkdir(jpath)

        for key in names:
            json_file = key + ".json"
            json_archive = os.path.join(jpath, json_file)

            fpath = os.path.join(dirname, key)
            msg = MailRequest('librelist.com', None, None, open(fpath).read())
            f = open(json_archive, "w")
            f.write(archive.to_json(msg.base))
            f.close()