def test_sendmail_rule_send_correct_products(event, order, item, item2): djmail.outbox = [] order.status = order.STATUS_PAID order.save() rule = event.sendmail_rules.create(send_date=dt_now - datetime.timedelta(hours=1), send_to=Rule.ATTENDEES, subject='meow', template='meow meow meow', all_products=False) rule.limit_products.set([item]) rule.save() p1 = order.all_positions.create(item=item, price=13, attendee_email='*****@*****.**') order.all_positions.create(item=item2, price=13, attendee_email='*****@*****.**') sendmail_run_rules(None) assert len(djmail.outbox) == 1 assert djmail.outbox[0].to[0] == p1.attendee_email
def test_sendmail_rule_send_correct_subevent(order, event_series, subevent1, subevent2, item): djmail.outbox = [] order.status = order.STATUS_PAID order.save() event_series.sendmail_rules.create(date_is_absolute=False, offset_is_after=False, send_offset_days=2, send_offset_time=datetime.time(9, 30), send_to=Rule.ATTENDEES, subject='meow', template='meow meow meow') p1 = order.all_positions.create(item=item, price=13, attendee_email='*****@*****.**', subevent=subevent1) order.all_positions.create(item=item, price=23, attendee_email='*****@*****.**', subevent=subevent2) sendmail_run_rules(None) assert len(djmail.outbox) == 1 assert djmail.outbox[0].to[0] == p1.attendee_email
def test_sendmail_rule_disabled(event, order): djmail.outbox = [] event.sendmail_rules.create(send_date=dt_now - datetime.timedelta(hours=1), include_pending=True, subject='meow', template='meow meow meow', enabled=False) sendmail_run_rules(None) assert len(djmail.outbox) == 0
def test_sendmail_rule_send_order_approval(event, order): djmail.outbox = [] order.require_approval = True order.save() event.sendmail_rules.create(send_date=dt_now - datetime.timedelta(hours=1), include_pending=True, subject='meow', template='meow meow meow') sendmail_run_rules(None) assert len(djmail.outbox) == 0
def test_sendmail_rule_send_both_same_email(order, event, item): djmail.outbox = [] order.status = order.STATUS_PAID order.save() order.all_positions.create(item=item, price=13, attendee_email='*****@*****.**') order.event.sendmail_rules.create(date_is_absolute=True, send_date=dt_now - datetime.timedelta(hours=1), send_to=Rule.BOTH, subject='meow', template='meow meow meow') sendmail_run_rules(None) assert len(djmail.outbox) == 1
def test_sendmail_rule_send_attendees_unset_mail(order, event, item): djmail.outbox = [] order.status = order.STATUS_PAID order.save() order.all_positions.create(item=item, price=13) order.event.sendmail_rules.create(date_is_absolute=True, send_date=dt_now - datetime.timedelta(hours=1), send_to=Rule.ATTENDEES, subject='meow', template='meow meow meow') sendmail_run_rules(None) assert len(djmail.outbox) == 1 mail = djmail.outbox[0] assert mail.to[0] == '*****@*****.**'
def test_sendmail_rule_recompute(event): event.has_subevents = True event.save() se1 = event.subevents.create(name="meow", date_from=dt_now) rule = event.sendmail_rules.create(date_is_absolute=False, offset_is_after=False, send_offset_days=1, send_offset_time=datetime.time(4, 30)) se1.date_from += datetime.timedelta(days=1) se1.save() expected = dt_now.replace(hour=4, minute=30, second=0, microsecond=0) sendmail_run_rules(None) m = ScheduledMail.objects.filter(rule=rule).first() assert m.computed_datetime.astimezone(utc) == expected
def test_sendmail_rule_send_order_vs_pos(send_to, amount_mails, recipients, order, event, item): djmail.outbox = [] order.status = order.STATUS_PAID order.save() order.event.sendmail_rules.create(date_is_absolute=True, send_date=dt_now - datetime.timedelta(hours=1), send_to=send_to, subject='meow', template='meow meow meow') order.all_positions.create(item=item, price=0, attendee_email='*****@*****.**') sendmail_run_rules(None) assert len(djmail.outbox) == amount_mails _recipients = [mail.to[0] for mail in djmail.outbox] assert set(recipients) == set(_recipients)