本文整理汇总了Python中users.User.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.set_password方法的具体用法?Python User.set_password怎么用?Python User.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.set_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_super_user
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import set_password [as 别名]
def add_super_user(self, name='admin', password=None):
""" Add a new user in the superuser group.
This is particularly handy to bootstrap a new system in pshell.
"""
user= User(self.request, firstname=name.capitalize(), lastname='User', groups=['superuser'], active=True, email='')
if not password:
password = generate_random_password()
user.set_password(password)
self['users'].add_child(name, user)
print "Created superuser with username %s and password %s" % (name, password)
示例2: UserTest
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import set_password [as 别名]
class UserTest(unittest.TestCase):
def setUp(self):
""" Setup Method to instance an object of Customer class """
code = 3606855
first_name = "Gretta"
last_name = "Rocha"
user_name = "grocha"
password = "gretita"
role = "Administrator"
status = "ACTIVE"
self.user = User(code, first_name, last_name, user_name, password, role, status)
self.user_test = User("11111", "Carla", "Illanes", "cillanes", "Carlita", "Employee", "ACTIVE")
def test_create_user(self):
""" Test if an instance of user class is created with the required data """
self.assertIsInstance(self.user_test, User)
def test_update_code_user(self):
""" Test if the user code is updated """
other_code = "55555"
self.user_test.set_code(other_code)
self.assertEqual(other_code, self.user_test.get_code())
def test_update_first_name_user(self):
""" Test if the first name of user is updated """
other_first_name = "Brenda"
self.user_test.set_first_name(other_first_name)
self.assertEqual(other_first_name, self.user_test.get_first_name())
def test_update_last_name_user(self):
""" Test if the last name of user is updated """
other_last_name = "Carpio"
self.user_test.set_last_name(other_last_name)
self.assertEqual(other_last_name, self.user_test.get_last_name())
def test_update_user_name(self):
""" Test if the user name is updated """
other_user_name = "bcarpio"
self.user_test.set_user_name(other_user_name)
self.assertEqual(other_user_name, self.user_test.get_user_name())
def test_update_password_user(self):
""" Test if the password of user is updated """
other_password = "Brendita"
self.user_test.set_password(other_password)
self.assertEqual(other_password, self.user_test.get_password())
def test_update_role_user(self):
""" Test if the role of user is updated """
other_role = "Visitor"
self.user_test.set_role(other_role)
self.assertEqual(other_role, self.user_test.get_role())
def test_update_status_user(self):
""" Test if the status of user is updated """
other_status = "INACTIVE"
self.user_test.set_status(other_status)
self.assertEqual(other_status, self.user_test.get_status())