def test_sends_to_user_with_verified(self, name, username, primary_email, address, expected): task = pretend.stub(delay=pretend.call_recorder(lambda *a, **kw: None)) request = pretend.stub(task=pretend.call_recorder(lambda x: task)) user = pretend.stub( name=name, username=username, primary_email=pretend.stub(email=primary_email, verified=True), ) if address is not None: address = pretend.stub(email=address, verified=True) msg = EmailMessage(subject="My Subject", body_text="My Body") email._send_email_to_user(request, user, msg, email=address) assert request.task.calls == [pretend.call(email.send_email)] assert task.delay.calls == [ pretend.call( expected, { "subject": "My Subject", "body_text": "My Body", "body_html": None }, ) ]
def test_sends_to_user_with_verified( self, name, username, primary_email, address, expected ): task = pretend.stub(delay=pretend.call_recorder(lambda *a, **kw: None)) request = pretend.stub(task=pretend.call_recorder(lambda x: task)) user = pretend.stub( name=name, username=username, primary_email=pretend.stub(email=primary_email, verified=True), ) if address is not None: address = pretend.stub(email=address, verified=True) msg = EmailMessage(subject="My Subject", body_text="My Body") email._send_email_to_user(request, user, msg, email=address) assert request.task.calls == [pretend.call(email.send_email)] assert task.delay.calls == [ pretend.call( expected, {"subject": "My Subject", "body_text": "My Body", "body_html": None}, ) ]
def test_doesnt_send_with_unverified(self, primary_email, address): task = pretend.stub(delay=pretend.call_recorder(lambda *a, **kw: None)) request = pretend.stub(task=pretend.call_recorder(lambda x: task)) user = pretend.stub(primary_email=pretend.stub( email=primary_email, verified=True if address is not None else False)) if address is not None: address = pretend.stub(email=address, verified=False) msg = EmailMessage(subject="My Subject", body_text="My Body") email._send_email_to_user(request, user, msg, email=address) assert request.task.calls == [] assert task.delay.calls == []
def test_doesnt_send_with_unverified(self, primary_email, address): task = pretend.stub(delay=pretend.call_recorder(lambda *a, **kw: None)) request = pretend.stub(task=pretend.call_recorder(lambda x: task)) user = pretend.stub( primary_email=pretend.stub( email=primary_email, verified=True if address is not None else False ) ) if address is not None: address = pretend.stub(email=address, verified=False) msg = EmailMessage(subject="My Subject", body_text="My Body") email._send_email_to_user(request, user, msg, email=address) assert request.task.calls == [] assert task.delay.calls == []