本文整理汇总了Python中models.Account.add_new_user方法的典型用法代码示例。如果您正苦于以下问题:Python Account.add_new_user方法的具体用法?Python Account.add_new_user怎么用?Python Account.add_new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.add_new_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Account_initialization
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import add_new_user [as 别名]
def test_Account_initialization(self):
try:
Account().put()
self.assertEqual(1,2)
except BadValueError:
pass
try:
Account(username='Captain Blackbeard').put()
self.assertEqual(1,2)
except BadValueError:
pass
try:
Account(email='[email protected]').put()
self.assertEqual(1,2)
except BadValueError:
pass
# test contructor
Account(username='Captain BlackBeard', email='[email protected]').put()
self.assertEqual(1, len(Account.query().fetch(2)))
# test add new user
request = AccountRequest('First Mate', '[email protected]')
Account.add_new_user(request)
self.assertEqual(2, len(Account.query().fetch(3)))
示例2: signup
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import add_new_user [as 别名]
def signup(self, request):
""" Adds a new user to the datastore
"""
# TODO: Add user authentication. Currently, we will create an acct
new_user = Account.add_new_user(request)
if new_user is None:
return AccountResponse(errmsg="Username already exists!")
return AccountResponse(id=new_user.key.id())