예제 #1
0
def test_chopped_url():
    msg = MailRequest('fakeperr', sender, list_addr, open("tests/data/chopped-url.msg").read())
    Router.deliver(msg)
    mlist = MailingList.objects.filter(email = list_addr)[0]
    links = mlist.link_set.all()
    assert len(links) == 2
    assert 'http://www.artic.edu/aic/collections/artwork/34145' in [link.url for link in links]
예제 #2
0
def test_gzip_attachment():

    clear_queue()
    
    # set up list and message
    name, address = parseaddr(gzip_msg['from'])
    client = RouterConversation(address, 'Files Tests')
    client.begin()
    mlist = mailinglist.find_list(list_name)
    test_subscribe_user(sender=address, client=client, mlist=mlist)
    
    test_subscribe_user(sender=parseaddr(sender)[1], client=sender_client, mlist=mlist)
    gzip_msg['to'] = list_addr

    # deliver the message.
    clear_queue()
    Router.deliver(gzip_msg)

    assert len(mlist.message_set.all()) == 1
    msg = mlist.message_set.all()[0]
    
    assert len(msg.file_set.all()) == 1
    attached = msg.file_set.all()[0]
    path = os.path.join(attached.pathprefix, attached.sha)
    assert attached.name in os.listdir(path)
    assert queue().count() == 1, "Should be 1 message in queue, but there are %s" % queue().count()
예제 #3
0
def test_long_url_1():
    msg = MailRequest('fakeperr', sender, list_addr, open("tests/data/long-url-1.msg").read())
    Router.deliver(msg)
    mlist = MailingList.objects.filter(email = list_addr)[0]
    links = mlist.link_set.all()
    assert len(links) == 1
    assert 'http://www.google.com/reader/view/#stream/feed%2Fhttp%3A%2F%2Fsethgodin.typepad.com%2Fseths_blog%2Findex.rdf' in [link.url for link in links]
예제 #4
0
def test_two_urls():
    msg = MailRequest('fakeperr', sender, list_addr, open("tests/data/two-urls.msg").read())
    Router.deliver(msg)
    mlist = MailingList.objects.filter(email = list_addr)[0]
    links = mlist.link_set.all()
    assert len(links) == 2
    assert 'http://www.rolfnelson.com/2009/11/your-work-habits-and-happiness.html' in [link.url for link in links]
    assert 'http://www.rolfnelson.com/2009/11/how-to-follow-through-emerging-science.html' in [link.url for link in links]
예제 #5
0
def test_complicated_archive_message():
    msg = MailRequest("fakeperr", sender, list_addr, open("tests/data/archive.msg").read())
    Router.deliver(msg)
    mlist = MailingList.objects.filter(email=list_addr)[0]
    messageid = mlist.message_set.all()[0].id
    jsmsg = json.loads(arch[str(messageid)])
    assert jsmsg["body"] == None
    assert len(jsmsg["parts"]) == 2
    assert "opted" in jsmsg["parts"][0]["body"]
    assert len(mlist.message_set.all()) == 1
예제 #6
0
def test_talking():

    """
    This message should move the state into
    TALKING.
    """

    msg = MailRequest('fakepeer', sender, "*****@*****.**", open(home("tests/data/emails/question.msg")).read())
    msg['From'] = sender
    Router.deliver(msg)
    q = queue.Queue(email('run/work'))
    assert q.count() == 2, "Queue count is actually %s" % str(q.count())
    assert delivered('Hi There!')
예제 #7
0
def test_get_work():

    """
    This message should move the state into
    TALKING.
    """
    # add some work to the work queue
    test_talking()
    
    msg = MailRequest('fakepeer', '*****@*****.**', "*****@*****.**", open(home("tests/data/emails/question.msg")).read())
    msg['From'] = '*****@*****.**'
    
    Router.deliver(msg)
    q = queue.Queue(email('run/work'))
    assert q.count() == 3, "Queue count is actually %s" % str(q.count())
    assert len(Answer.objects.all()) == 4, "Oops. There are actually %s answers in the db, expected 4." % str(len(Answer.objects.all()))
예제 #8
0
def test_good_confirmation(msg=None):

    """
    This message should move the state into
    ALERTING.
    """
    alert = create_alert()
    
    addr = "*****@*****.**" % alert.id
    if not msg:
        msg = MailRequest('fakepeer', sender, addr, open(home("tests/data/emails/confirmation.msg")).read())
    msg['to'] = addr
    Router.deliver(msg)
    q = queue.Queue(email('run/alerts'))
    assert q.count() == 0
    assert_in_state('app.handlers.alerts', msg['to'], sender, 'ALERTING') 
예제 #9
0
def test_two_attachments():
    name, address = parseaddr(deneen_msg['from'])
    client = RouterConversation(address, 'Files Tests')
    test_subscribe_user(sender=address, client=client)
    Router.deliver(two_msg)
    mlist = mailinglist.find_list(list_name)
    assert len(mlist.message_set.all()) == 1

    msg = mlist.message_set.all()[0]
    assert len(msg.file_set.all()) == 2
    attached = msg.file_set.all()[0]
    path = os.path.join(attached.pathprefix, attached.sha)
    assert os.listdir(path)[0] == attached.name

    attached = msg.file_set.all()[1]
    path = os.path.join(attached.pathprefix, attached.sha)
    assert os.listdir(path)[0] == attached.name
예제 #10
0
def test_add_karma():
    test_get_work()
    
    ans_u = User.objects.filter(email='*****@*****.**')[0]
    
    u = User.objects.filter(email=sender).all()[0]
    conv = Conversation.objects.filter(user=u).all()[0]
    s = Snip.objects.filter(conversation=conv).all()[0]
    answer = Answer.objects.filter(snip=s).all()[0]
    
    ans = MailRequest('fakepeer', '*****@*****.**', "*****@*****.**" % answer.id, open(home("tests/data/emails/answer.msg")).read())
    ans['From'] = '*****@*****.**'
    ans['To'] = "*****@*****.**" % answer.id
    Router.deliver(ans)
    
    ans_u = User.objects.filter(email='*****@*****.**')[0]
    
    assert ans_u.karma == 0
예제 #11
0
def test_incoming_alert():
    """
    Verify an incoming alert generates
    the correct database records.
    """
    alert = create_alert()

    
    msg = MailRequest('fakepeer', sender, "*****@*****.**" % alert.id, open(home("tests/data/emails/alerts.msg")).read())
    msg['to'] = "*****@*****.**" % alert.id
    Router.deliver(msg)

    #Should error out in the alerts.py handlers module in CONFIRMING
    #because these messages are dumped in the alertsq to be handled asyncronously,
    #but the testing environment just sends it to both modules at the same time.
    q = queue.Queue(email('run/error'))
    assert q.count() == 1
    
    assert len(Blurb.objects.all()) == 26, "There are %s blurbs." % len(Blurb.objects.all())
예제 #12
0
def test_soft_bounce_tells_them():
    setup()

    # get them into a posting state
    admin_tests.test_existing_user_posts_message()
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    clear_queue()
    assert mailinglist.find_subscriptions(sender, list_addr)

    # force them to soft bounce
    msg = create_bounce(list_addr, sender)
    msg.bounce.primary_status = (3, bounce.PRIMARY_STATUS_CODES[u'3'])
    assert msg.bounce.is_soft()

    Router.deliver(msg)
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')
    assert_in_state('app.handlers.bounce', list_addr, sender, 'BOUNCING')
    assert not delivered('unbounce'), "We shouldn't be sending on bounde."
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
    assert not mailinglist.find_subscriptions(sender, list_addr)

    # make sure that any attempts to post return a "you're bouncing dude" message
    client.say(list_addr, 'So anyway as I was saying.')
    assert not delivered('unbounce')
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')

    # now have them try to unbounce
    msg = client.say('*****@*****.**', "Please put me back on, I'll be good.",
                     'unbounce-confirm')

    # handle the bounce confirmation
    client.say(msg['from'], "Confirmed to unbounce.", 'noreply')

    # alright they should be in the unbounce state for the global bounce handler
    assert_in_state('app.handlers.bounce', list_addr, sender,
                    'UNBOUNCED')

    # and they need to be back to POSTING for regular operations 
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    assert mailinglist.find_subscriptions(sender, list_addr)

    # and make sure that only the original bounce is in the bounce archive
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
예제 #13
0
파일: bounce_tests.py 프로젝트: 3kwa/lamson
def test_soft_bounce_tells_them():
    setup()

    # get them into a posting state
    admin_tests.test_existing_user_posts_message()
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    clear_queue()
    assert mailinglist.find_subscriptions(sender, list_addr)

    # force them to soft bounce
    msg = create_bounce(list_addr, sender)
    msg.bounce.primary_status = (3, bounce.PRIMARY_STATUS_CODES[u'3'])
    assert msg.bounce.is_soft()

    Router.deliver(msg)
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')
    assert_in_state('app.handlers.bounce', list_addr, sender, 'BOUNCING')
    assert delivered('unbounce'), "Looks like unbounce didn't go out."
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
    assert not mailinglist.find_subscriptions(sender, list_addr)

    # make sure that any attempts to post return a "you're bouncing dude" message
    unbounce = client.say(list_addr, 'So anyway as I was saying.', 'unbounce')
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')

    # now have them try to unbounce
    msg = client.say(unbounce['from'], "Please put me back on, I'll be good.",
                     'unbounce-confirm')

    # handle the bounce confirmation
    client.say(msg['from'], "Confirmed to unbounce.", 'noreply')

    # alright they should be in the unbounce state for the global bounce handler
    assert_in_state('app.handlers.bounce', list_addr, sender,
                    'UNBOUNCED')

    # and they need to be back to POSTING for regular operations 
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    assert mailinglist.find_subscriptions(sender, list_addr)

    # and make sure that only the original bounce is in the bounce archive
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
예제 #14
0
def _settings_loader():
    from lamson.routing import Router
    from lamson.server import Relay, SMTPReceiver
    from lamson import view, queue
    import logging
    import logging.config
    import jinja2

    settings = Settings()
    for attr_name in dir(django_settings):
        if attr_name.startswith("LAMSON_"):
            setattr(settings,
                    attr_name.split("LAMSON_")[1].lower(),
                    getattr(django_settings, attr_name))

    #logging.config.fileConfig("logging.conf")

    # the relay host to actually send the final message to
    #TODO make debug a parameter to the command
    if hasattr(settings, 'relay_config'):
        settings.relay = Relay(host=settings.relay_config['host'],
                               port=settings.relay_config['port'],
                               debug=1)

    # where to listen for incoming messages
    settings.receiver = SMTPReceiver(settings.receiver_config['host'],
                                     settings.receiver_config['port'])

    Router.defaults(**settings.router_defaults)
    Router.load(settings.handlers)
    #TODO make this a parameter to the command
    Router.RELOAD = True
    #TODO make run a parameter to the command
    Router.UNDELIVERABLE_QUEUE = queue.Queue("run/undeliverable")

    if hasattr(settings, 'template_config'):
        view.LOADER = jinja2.Environment(
            loader=jinja2.PackageLoader(settings.template_config['dir'],
                                        settings.template_config['module']))

    return settings
예제 #15
0
def _settings_loader():
    from lamson.routing import Router
    from lamson.server import Relay, SMTPReceiver
    from lamson import view, queue
    import logging
    import logging.config
    import jinja2

    settings = Settings()
    for attr_name in dir(django_settings):
    	if attr_name.startswith("LAMSON_"):
    		setattr(settings, attr_name.split("LAMSON_")[1].lower(),
             getattr(django_settings, attr_name))

    #logging.config.fileConfig("logging.conf")

    # the relay host to actually send the final message to
    #TODO make debug a parameter to the command
    if hasattr(settings, 'relay_config'):
        settings.relay = Relay(host=settings.relay_config['host'],
                               port=settings.relay_config['port'], debug=1)

    # where to listen for incoming messages
    settings.receiver = SMTPReceiver(settings.receiver_config['host'],
                                     settings.receiver_config['port'])

    Router.defaults(**settings.router_defaults)
    Router.load(settings.handlers)
    #TODO make this a parameter to the command
    Router.RELOAD=True
    #TODO make run a parameter to the command
    Router.UNDELIVERABLE_QUEUE=queue.Queue("run/undeliverable")

    if hasattr(settings, 'template_config'):
        view.LOADER = jinja2.Environment(
            loader=jinja2.PackageLoader(settings.template_config['dir'],
                                        settings.template_config['module']))

    return settings
예제 #16
0
def test_one_attachment():

    #subscribe the original sender
    name, address = parseaddr(deneen_msg['from'])
    client = RouterConversation(address, 'Files Tests')
    test_subscribe_user(sender=address, client=client)

    # add someone else to the list
    test_subscribe_user(sender=sender, client=sender_client)

    # update the message to send to the list we just created.
    deneen_msg['to'] = list_addr

    Router.deliver(deneen_msg)
    mlist = mailinglist.find_list(list_name)
    assert len(mlist.message_set.all()) == 1
    msg = mlist.message_set.all()[0]
    
    assert len(msg.file_set.all()) == 1
    attached = msg.file_set.all()[0]
    path = os.path.join(attached.pathprefix, attached.sha)
    assert attached.name in os.listdir(path)
    assert_in_state('app.handlers.admin', deneen_msg['to'], address, 'POSTING')
예제 #17
0
def test_continue_conversation():

    """
    Start a conversation, get a response, continue the conversation.
    """

    test_talking()
    assert len(Conversation.objects.all()) == 1
    assert len(User.objects.all()) == 1
    u = User.objects.all()[0]
    c = Conversation.objects.all()[0]
    talking.continue_conversation(u)
    assert delivered('Hmmm...')
    c = Conversation.objects.all()[0]
    assert c.pendingprompt == True
    to = "*****@*****.**" % str(c.id)
    msg = MailRequest('fakepeer', sender, to, open(home("tests/data/emails/question.msg")).read())
    msg['to'] = to
    msg['from'] = sender
    #TODO: this doesn't affect state for some reason.
    Router.deliver(msg)
    assert len(Conversation.objects.all()) == 1
    assert len(User.objects.all()) == 1
def test_hard_bounce_disables_user():
    # get them into a posting state
    admin_tests.test_existing_user_posts_message()
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    clear_queue()
    assert mailinglist.find_subscriptions(sender, list_addr)

    # force them to HARD bounce
    msg = create_bounce(list_addr, sender)

    Router.deliver(msg)
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')
    assert_in_state('app.handlers.bounce', list_addr, sender, 'BOUNCING')
    assert not delivered('unbounce'), "A HARD bounce should be silent."
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
    assert not mailinglist.find_subscriptions(sender, list_addr)

    # make sure that any attempts to post return a "you're bouncing dude" message
    unbounce = client.say(list_addr, 'So anyway as I was saying.', 'unbounce')
    assert_in_state('app.handlers.admin', list_addr, sender, 'BOUNCING')

    # now have them try to unbounce
    msg = client.say(unbounce['from'], "Please put me back on, I'll be good.",
                     'unbounce-confirm')

    # handle the bounce confirmation
    client.say(msg['from'], "Confirmed to unbounce.", 'noreply')

    # alright they should be in the unbounce state for the global bounce handler
    assert_in_state('app.handlers.bounce', list_addr, sender, 'UNBOUNCED')

    # and they need to be back to POSTING for regular operations
    assert_in_state('app.handlers.admin', list_addr, sender, 'POSTING')
    assert mailinglist.find_subscriptions(sender, list_addr)

    # and make sure that only the original bounce is in the bounce archive
    assert_equal(len(queue(queue_dir=settings.BOUNCE_ARCHIVE).keys()), 1)
예제 #19
0
def test_confirm_then_alert():
    """
    An alert sent after an account is confirmed should go right into
    ALERTING and alert objects should be created in the database.
    """
    alert = create_alert()

    addr = "*****@*****.**" % alert.id

    confirm = MailRequest('fakepeer', sender, addr, open(home("tests/data/emails/confirmation.msg")).read())
    confirm['to'] = addr
    test_good_confirmation(msg=confirm)


    alertsmsg = MailRequest('fakepeer', "different@sender", addr, open(home("tests/data/emails/alerts.msg")).read())
    alertsmsg['to'] = addr
    Router.deliver(alertsmsg)

    # there are 10 alerts in this alert email. since this is the test environment it will be dumped
    # into the alerts queue automatically, which will create the 10 alerts. Then it should be processed
    # by the alerts handler module, dumped into the queue again, thereby upping the alerts queue by one.
    assert len(Blurb.objects.all()) == 26, "There are %s blurbs." % len(Blurb.objects.all())
    q = queue.Queue(email('run/alerts'))
    assert q.count() == 1
예제 #20
0
def test_spam_sent_by_confirmed_user():
    test_confirmed_user_comments()
    clear_queue("run/posts")

    Router.deliver(make_spam())
예제 #21
0
def test_spam_sent_by_unconfirmed_user():
    setup()

    client.begin()
    Router.deliver(make_spam())
예제 #22
0
파일: forward.py 프로젝트: 3kwa/lamson
from config import settings
from lamson.routing import Router
from lamson.server import Relay, QueueReceiver
from lamson import view
import logging
import logging.config
import jinja2

# configure logging to go to a log file
logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'], 
                       port=settings.relay_config['port'], debug=1)

# where to listen for incoming messages
settings.receiver = QueueReceiver('run/undeliverable', settings.queue_config['sleep'])

Router.defaults(**settings.router_defaults)
Router.load(['lamson.handlers.forward'])
Router.RELOAD=True
Router.UNDELIVERABLE_QUEUE=None

view.LOADER = jinja2.Environment(
    loader=jinja2.PackageLoader(settings.template_config['dir'], 
                                settings.template_config['module']))

예제 #23
0
파일: queue.py 프로젝트: sfioritto/lookout
from config import settings
from lamson.routing import Router
from lamson.server import Relay, QueueReceiver
from lamson import view
import logging
import logging.config
import jinja2

logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'], 
                       port=settings.relay_config['port'], debug=1)

# where to listen for incoming messages
settings.receiver = QueueReceiver(settings.alertsq_config['queue'],
                                 settings.alertsq_config['sleep'])

Router.defaults(**settings.router_defaults)
Router.load(settings.alertsq_handlers)
Router.RELOAD=False

view.LOADER = jinja2.Environment(
    loader=jinja2.PackageLoader(settings.template_config['dir'], 
                                settings.template_config['module']))

예제 #24
0
def test_bounce_to_decorator():
    import bounce_filtered_mod
    msg = mail.MailRequest(None, None, None, open("tests/bounce.msg").read())

    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.START, msg)
    assert bounce_filtered_mod.HARD_RAN, "Hard bounce state didn't actually run: %r" % msg.route_to

    msg.bounce.primary_status = (4, u'Persistent Transient Failure')
    Router.clear_states()
    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.START, msg)
    assert bounce_filtered_mod.SOFT_RAN, "Soft bounce didn't actually run."

    msg = mail.MailRequest(None, None, None, open("tests/signed.msg").read())
    Router.clear_states()
    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.END,
                           msg), "Regular messages aren't delivering."
예제 #25
0
def test_log_handler():
    Router.deliver(message_tests.test_mail_request())
예제 #26
0
파일: testing.py 프로젝트: 3kwa/lamson
from lamson.routing import Router
from lamson.server import Relay
import jinja2
import logging
import logging.config
import os

# configure logging to go to a log file
logging.config.fileConfig("tests/config/logging.conf")

# the relay host to actually send the final message to (set debug=1 to see what
# the relay is saying to the log server).
settings.relay = Relay(host=settings.relay_config['host'], 
                       port=settings.relay_config['port'], debug=0)


settings.receiver = None

Router.defaults(**settings.router_defaults)
Router.load(settings.handlers + settings.queue_handlers)
Router.RELOAD=False
Router.LOG_EXCEPTIONS=False

view.LOADER = jinja2.Environment(loader=jinja2.PackageLoader('lamson_tests', 'templates'))

# if you have pyenchant and enchant installed then the template tests will do
# spell checking for you, but you need to tell pyenchant where to find itself
if 'PYENCHANT_LIBRARY_PATH' not in os.environ:
    os.environ['PYENCHANT_LIBRARY_PATH'] = '/opt/local/lib/libenchant.dylib'

예제 #27
0
파일: mailconf.py 프로젝트: emulbreh/ecs
import os
import logging
import logging.config

from django.conf import settings

from lamson.routing import Router
from lamson.server import Relay, SMTPReceiver
from lamson import queue

import ecs.ecsmail.monkey

relay = Relay(host= settings.EMAIL_HOST, port= settings.EMAIL_PORT, starttls= settings.EMAIL_USE_TLS,
    username = settings.EMAIL_HOST_USER, password= settings.EMAIL_HOST_PASSWORD)
# Monkey Patch deliver so it will use ecsmail settings (and django backends)
relay.deliver = ecs.ecsmail.monkey.deliver 

receiver = SMTPReceiver(settings.ECSMAIL ['listen'], settings.ECSMAIL ['port'])

Router.defaults(host= '.+')
Router.load(settings.ECSMAIL ['handlers'])
Router.RELOAD = False
Router.UNDELIVERABLE_QUEUE = queue.Queue(settings.ECSMAIL ['queue_dir'])
예제 #28
0
from config import settings
from lamson.routing import Router
from lamson.server import Relay, SMTPReceiver, QueueReceiver
from lamson import view, queue
import logging
import logging.config
import jinja2

logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'],
                       port=settings.relay_config['port'],
                       debug=1)

# where to listen for incoming messages
#settings.receiver = SMTPReceiver(settings.receiver_config['host'],
#                                 settings.receiver_config['port'])

# b0nd - include the maildir option we've set in settings.py
settings.receiver = QueueReceiver(settings.receiver_config['maildir'])

Router.defaults(**settings.router_defaults)
Router.load(settings.handlers)
Router.RELOAD = True
Router.UNDELIVERABLE_QUEUE = queue.Queue("run/undeliverable")

view.LOADER = jinja2.Environment(loader=jinja2.PackageLoader(
    settings.template_config['dir'], settings.template_config['module']))
예제 #29
0
from config import settings
from lamson.routing import Router
from lamson.server import Relay, QueueReceiver
from lamson import view
import logging
import logging.config
import jinja2

# configure logging to go to a log file
logging.config.fileConfig("config/logging.conf")

# the relay host to actually send the final message to
settings.relay = Relay(host=settings.relay_config['host'],
                       port=settings.relay_config['port'],
                       debug=1)

# where to listen for incoming messages
settings.receiver = QueueReceiver('run/undeliverable',
                                  settings.queue_config['sleep'])

Router.defaults(**settings.router_defaults)
Router.load(['lamson.handlers.forward'])
Router.RELOAD = True
Router.UNDELIVERABLE_QUEUE = None

view.LOADER = jinja2.Environment(loader=jinja2.PackageLoader(
    settings.template_config['dir'], settings.template_config['module']))
예제 #30
0
파일: bounce_tests.py 프로젝트: 3kwa/lamson
def test_bounce_to_decorator():
    import bounce_filtered_mod
    msg = mail.MailRequest(None,None,None, open("tests/bounce.msg").read())

    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.START, msg)
    assert bounce_filtered_mod.HARD_RAN, "Hard bounce state didn't actually run: %r" % msg.route_to

    msg.bounce.primary_status = (4, u'Persistent Transient Failure')
    Router.clear_states()
    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.START, msg)
    assert bounce_filtered_mod.SOFT_RAN, "Soft bounce didn't actually run."

    msg = mail.MailRequest(None, None, None, open("tests/signed.msg").read())
    Router.clear_states()
    Router.deliver(msg)
    assert Router.in_state(bounce_filtered_mod.END, msg), "Regular messages aren't delivering."
예제 #31
0
def setup():
    Router.clear_routes()
    Router.clear_states()
    Router.load(['lamson_tests.simple_fsm_mod'])
예제 #32
0
def test_queue_handler():
    Router.deliver(message_tests.test_mail_request())
예제 #33
0
def setup():
    Router.clear_routes()
    Router.clear_states()
    Router.load(['lamson_tests.simple_fsm_mod'])
예제 #34
0
def test_bad_confirmation():
    Router.deliver(badmsg)
    q = queue.Queue(email('run/error'))
    assert q.count() == 2 #one for the alertsq module and one for alerts
    assert_in_state('app.handlers.alerts', badmsg['to'], sender, 'CONFIRMING')