Exemplo n.º 1
0
    def test_send_reset_email(self):
        # send email
        mailer.send_reset_link(model.User.by_name(u"bob"))

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config["smtp.mail_from"])
        assert_equal(msg[2], [model.User.by_name(u"bob").email])
        assert "Reset" in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(model.User.by_name(u"bob"))
        expected_body = self.mime_encode(test_msg, u"bob")
        assert expected_body in msg[3], "%r not in %r" % (expected_body, msg[3])
    def test_send_reset_email(self):
        # send email
        mailer.send_reset_link(model.User.by_name(u'bob'))

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [model.User.by_name(u'bob').email])
        assert 'Reset' in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(model.User.by_name(u'bob'))
        expected_body = self.mime_encode(test_msg, u'bob')
        assert expected_body in msg[3], '%r not in %r' % (expected_body,
                                                          msg[3])
Exemplo n.º 3
0
    def test_send_reset_email(self):
        # send email
        send_reset_link(model.User.by_name(u'bob'))
        time.sleep(0.1)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [model.User.by_name(u'bob').email])
        assert 'Reset' in msg[3], msg[3]
        test_msg = get_reset_link_body(model.User.by_name(u'bob'))
        expected_body = self.mime_encode(test_msg,
                                         u'bob') 
        assert expected_body in msg[3], '%r not in %r' % (expected_body, msg[3])
Exemplo n.º 4
0
    def test_send_reset_email(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [user['email']])
        assert 'Reset' in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(user_obj)
        expected_body = self.mime_encode(test_msg, user['name'])

        assert_in(expected_body, msg[3])
Exemplo n.º 5
0
    def test_send_reset_email(self, mail_server):
        user = factories.User()
        user_obj = model.User.by_name(user["name"])

        mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = mail_server.get_smtp_messages()
        assert len(msgs) == 1
        msg = msgs[0]
        assert msg[1] == config["smtp.mail_from"]
        assert msg[2] == [user["email"]]
        assert "Reset" in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(user_obj)
        expected_body = self.mime_encode(test_msg + '\n', user["name"])

        assert expected_body in msg[3]
Exemplo n.º 6
0
    def test_send_reset_email(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [user['email']])
        assert 'Reset' in msg[3], msg[3]
        test_msg = mailer.get_reset_link_body(user_obj)
        expected_body = self.mime_encode(test_msg,
                                         user['name'])

        assert_in(expected_body, msg[3])
Exemplo n.º 7
0
    def test_send_reset_email(self):
        user = factories.User()
        user_obj = model.User.by_name(user['name'])

        # We need to provide a context as url_for is used internally
        with self.app.flask_app.test_request_context():
            mailer.send_reset_link(user_obj)

        # check it went to the mock smtp server
        msgs = self.get_smtp_messages()
        assert_equal(len(msgs), 1)
        msg = msgs[0]
        assert_equal(msg[1], config['smtp.mail_from'])
        assert_equal(msg[2], [user['email']])
        assert 'Reset' in msg[3], msg[3]
        # We need to provide a context as url_for is used internally
        with self.app.flask_app.test_request_context():
            test_msg = mailer.get_reset_link_body(user_obj)
        expected_body = self.mime_encode(test_msg, user['name'])

        assert_in(expected_body, msg[3])