Beispiel #1
0
def test_unsent_one():
    ps = PendingSend()
    ps.toaddr = '*****@*****.**'
    ps.template_name = 'template-1'
    ps.template_vars = {"foo": 'bar'}
    ps.save()

    unsent = list(PendingSend.Unsent())
    assert len(unsent) == 1
    ps = unsent[0]
    toaddr = ps.toaddr
    assert toaddr == '*****@*****.**'
Beispiel #2
0
nemesis_root = os.path.dirname(os.path.abspath(__file__)) + "/../"
sys.path.insert(0, nemesis_root)

import config
from sqlitewrapper import PendingSend

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="List pending email sends.",
    )
    parser.add_argument(
        '--limit',
        default=1000,
        type=int,
        help="The maximum number of emails to list (default: %(default)s).",
    )
    parser.add_argument(
        '--max-retries',
        default=5,
        type=int,
        help="Restrict to emails with up to this many retry attempts (default: "
             "%(default)s).",
    )
    args = parser.parse_args()

    for ps in PendingSend.Unsent(
        max_results=args.limit,
        max_retry=args.max_retries + 1,
    ):
        print(ps)
Beispiel #3
0
def test_unsent_none():
    unsent = list(PendingSend.Unsent())
    assert len(unsent) == 0
Beispiel #4
0
def send_emails(limit=50, max_retry=5):
    unsent_mails = PendingSend.Unsent(max_retry=max_retry, max_results=limit)
    for ps in unsent_mails:
        mailer.try_send(ps)