コード例 #1
0
ファイル: test_init.py プロジェクト: ytaniguchi8/warehouse
    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
                },
            )
        ]
コード例 #2
0
ファイル: test_init.py プロジェクト: craig5/warehouse
    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},
            )
        ]
コード例 #3
0
ファイル: test_init.py プロジェクト: ytaniguchi8/warehouse
    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 == []
コード例 #4
0
ファイル: test_init.py プロジェクト: craig5/warehouse
    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 == []