本文整理汇总了Python中model.user.User.insert方法的典型用法代码示例。如果您正苦于以下问题:Python User.insert方法的具体用法?Python User.insert怎么用?Python User.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_user_info
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import insert [as 别名]
def init_user_info():
"""Initialize user info to db."""
name = "suwen"
password = salt_password("xxxxxx")
email = "[email protected]"
user = User(name=name, password=password, email=email)
user.insert()
示例2: test_insert
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import insert [as 别名]
def test_insert(self):
d = dict(email="[email protected]", password="1234", password2="1234")
yield User.insert(**d)
user = yield User.col.find_one({'email': d['email']})
assert user.get('email') == d['email']
yield User.col.remove({'email': d['email']})
d2 = dict(email="[email protected]", password="1234", password2="1")
with pytest.raises(ValidationError) as e:
yield User.insert(**d2)
assert 'insert error' == e.value.message
示例3: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import insert [as 别名]
def post(self):
post_data = self.__check_request(request.form)
source = string.digits + string.ascii_letters
token = ''.join(map(str, [source[randint(0, len(source) -1) ] for x in range(0,18)]))
org = Organization.find(1)
user = User(name=post_data['name'],
mail_address=post_data['mail_address'],
password=post_data['password'],
token=token,
organization_id=org.id
)
user.insert()
return jsonify(status=200, message='ok', request=request.form, response={'token':token})
示例4: test_check_password
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import insert [as 别名]
def test_check_password(self):
d = dict(email="[email protected]", password="1234", password2="1234")
yield User.insert(**d)
assert (yield User.check_password(d['email'], d['password'])) == True
assert (yield User.check_password(d['email'], '')) == False
yield User.col.remove({'email': d['email']})