本文整理汇总了Python中src.models.user.User.save_to_db方法的典型用法代码示例。如果您正苦于以下问题:Python User.save_to_db方法的具体用法?Python User.save_to_db怎么用?Python User.save_to_db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.models.user.User
的用法示例。
在下文中一共展示了User.save_to_db方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_simple_user_to_db
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import save_to_db [as 别名]
def test_save_simple_user_to_db(self):
email = "[email protected]"
user = User(email, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
user.permissions = Permissions.default().name
user.save_to_db()
self.assertIsNotNone(User.find_by_email(email))
Database.remove("users", {"email": email})
示例2: test_save_complex_user_to_db
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import save_to_db [as 别名]
def test_save_complex_user_to_db(self):
email = "[email protected]"
encrypted_password = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
country = "Spain"
university = "Abertay"
user = User(email, encrypted_password)
user.data['country'] = country
user.data['university'] = university
user.permissions = Permissions.default().name
user.save_to_db()
user_from_db = User.find_by_email(email)
self.assertEqual(user_from_db.email, email)
self.assertEqual(user_from_db.encrypted_password, encrypted_password)
self.assertEqual(user_from_db.data['country'], country)
self.assertEqual(user_from_db.data['university'], university)
Database.remove("users", {"email": email})