def testLinkWorksCorrectly(self, send_email): test_user = User.query.filter_by(name=self.TEST_USER).one_or_none() test_link = '123456789' expected_test_link = 'http://localhost:5000/activate/123456789' commenting_user = '******' with app.app_context(): send_activation_email(test_user, test_link) send_reset_email(test_user, test_link) send_comment_email(self.TEST_USER_EMAIL, 'test_user', 'pkg', commenting_user) send_welcome_email(test_user) assert send_email.called call = send_email.call_args_list[0][1] html = call['html'] body = call['body'] assert html.find(expected_test_link) != -1 assert body.find(expected_test_link) != -1 expected_test_link = 'http://localhost:3000/reset_password/123456789' call = send_email.call_args_list[1][1] html = call['html'] body = call['body'] assert html.find(expected_test_link) != -1 assert body.find(expected_test_link) != -1 expected_test_link = 'http://localhost:3000/package/test_user/pkg/comments' call = send_email.call_args_list[2][1] html = call['html'] body = call['body'] assert html.find(expected_test_link) != -1 assert body.find(expected_test_link) != -1 assert html.find(commenting_user) != -1 assert body.find(commenting_user) != -1
def main(argv): if len(argv) > 1: print("Usage: %s" % argv[0], file=sys.stderr) return 1 username = input("Username: "******"Email: ") password1 = getpass.getpass("Password: "******"Error: %s" % ex.message, file=sys.stderr) return 2 password2 = getpass.getpass("Confirm password: "******"Passwords don't match!", file=sys.stderr) return 2 try: with app.app_context(): _create_user(username, password=password1, email=email, is_admin=True, requires_activation=False) db.session.commit() except AuthException as ex: print("Error: %s" % ex.message, file=sys.stderr) return 2 print("Success.") return 0
def testTemplates(self, send_email): # just make sure all templates work test_user = User.query.filter_by(name=self.TEST_USER).one_or_none() with app.app_context(): send_new_user_email(self.TEST_USER, self.TEST_USER_EMAIL, ['*****@*****.**', '*****@*****.**']) send_invitation_email(self.TEST_USER_EMAIL, self.OTHER_USER, 'test') send_reset_email(test_user, 'test') send_activation_email(test_user, 'test')
def testLinkWorksCorrectly(self, send_email): test_user = User.query.filter_by(name=self.TEST_USER).one_or_none() test_link = '123456789' expected_test_link = 'http://localhost:5000/activate/123456789' with app.app_context(): send_activation_email(test_user, test_link) send_reset_email(test_user, test_link) assert send_email.called call = send_email.call_args_list[0][1] html = call['html'] body = call['body'] assert html.find(expected_test_link) != -1 assert body.find(expected_test_link) != -1 expected_test_link = 'http://localhost:3000/reset_password/123456789' call = send_email.call_args_list[1][1] html = call['html'] body = call['body'] assert html.find(expected_test_link) != -1 assert body.find(expected_test_link) != -1