コード例 #1
0
ファイル: test_email.py プロジェクト: mason478/Flasklearning
    def test_email(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()

        def send_async_email(app, msg):
            with self.app_context:
                mail.send(msg)

        def send_email(subject, to, text, **kwargs):
            msg = Message(subject=subject,
                          sender='*****@*****.**',
                          recipients=[to])
            msg.body = text
            thr = Thread(target=send_async_email, args=[current_app, msg])
            thr.start()
            return thr

        u = User(email='*****@*****.**', username='******', password='******')
        db.session.add(u)
        db.session.commit()
        token = u.generate_confirmation_token()
        send_email(subject='Confirm your account',
                   to='*****@*****.**',
                   text='Helo,test')
コード例 #2
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()  #Why must have context?
     db.create_all()
     u = User(email='*****@*****.**', username='******', password='******')
     db.session.add(u)
     db.session.commit()
コード例 #3
0
ファイル: test_email.py プロジェクト: mason478/Flasklearning
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()