本文整理汇总了Python中users.User.create方法的典型用法代码示例。如果您正苦于以下问题:Python User.create方法的具体用法?Python User.create怎么用?Python User.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_assign_user_to_group
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_assign_user_to_group(self):
anons = Group.create(name='anons')
jhondohe = User.create(name='jhondhoe', password='pass')
anons.users.add(jhondohe)
anons.save()
eq_(jhondohe.groups.count(), 1)
eq_(jhondohe.groups.get().id, anons.id)
示例2: test_user_change_password
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_change_password(self):
u = User.create(name='test', password='pass_1')
u = User.get(User.name == 'test')
u.set_password('pass_2')
u.save()
u = User.get(User.name == 'test')
ok_(not u.verify_password('pass_1'))
ok_(u.verify_password('pass_2'))
示例3: test_remove_user_from_group
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_remove_user_from_group(self):
anons = Group.create(name='anons')
jhondohe = User.create(name='jhondhoe', password='pass')
anons.users.add(jhondohe)
anons.save()
anons.users.remove(jhondohe)
anons.save()
eq_(jhondohe.groups.count(), 0)
eq_(UserToGroup.select().count(), 0)
示例4: test_assign_user_to_multiple_group
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_assign_user_to_multiple_group(self):
rebels = Group.create(name='rebels')
aliens = Group.create(name='aliens')
allGroups = [aliens, rebels]
# https://en.wikipedia.org/wiki/They_Live
user = User.create(name='doubtful')
user.groups.add(allGroups)
belongsID = [g.id for g in user.groups]
allGroupsID = [g.id for g in allGroups]
eq_((set(belongsID), len(belongsID)), (set(allGroupsID), len(allGroupsID)))
示例5: test_assign_duplicate_user_to_group
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_assign_duplicate_user_to_group(self):
anons = Group.create(name='anons')
jhondohe = User.create(name='jhondhoe', password='pass')
anons.users.add(jhondohe)
anons.save()
with self.assertRaises(IntegrityError):
anons.users.add(jhondohe)
anons.save()
eq_(jhondohe.groups.count(), 1)
eq_(jhondohe.groups.get().id, anons.id)
示例6: populate
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def populate(self):
with self.udb.atomic():
cap1 = Capability.create(domain='res1', action=Action.READ)
cap2 = Capability.create(domain='res2', action=Action.UPDATE)
grp1 = Group.create(name='grp2')
grp2 = Group.create(name='grp1')
usr = User.create(name='usr')
grp1.capabilities.add(cap1)
grp2.capabilities.add(cap2)
usr.groups.add([grp1, grp2])
return usr, [cap1, cap2]
示例7: post
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def post(self, user_id="__INVALID__"):
# --- VALIDATION ----
if user_id != "__INVALID__":
raise MethodNotAllowedError
user = request.get_json()
# --- DATA METHOD ---
user_data = User()
return user_data.create(user)
示例8: test_user_can
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_can(self):
cap1 = Capability.create(domain=Capability.simToReg('volumes/*'),
action=Action.CREATE | Action.READ)
cap2 = Capability.create(domain=Capability.simToReg('volumes/123'),
action=Action.UPDATE)
grp1 = Group.create(name='grp2')
grp2 = Group.create(name='grp1')
usr = User.create(name='usr')
grp1.capabilities.add(cap1)
grp2.capabilities.add(cap2)
usr.groups.add([grp1, grp2])
self.assertTrue(usr.can('volumes/61273', action=Action.CREATE))
self.assertTrue(usr.can('volumes/123', Action.CREATE | Action.READ))
self.assertFalse(usr.can('volumes/82828', Action.DELETE))
self.assertFalse(usr.can('volumes/123', Action.DELETE))
示例9: test_user_creation
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_creation(self):
newUser = User.create(name='test', password='pass')
User.get(User.name == newUser.name)
eq_(User.select().count(), 1)
示例10: test_user_verify_wrong_password
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_verify_wrong_password(self):
User.create(name='test', password='pass')
ok_(not User.get(User.name == 'test').verify_password('wrong_pass'))
示例11: test_user_verify_right_password
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_verify_right_password(self):
User.create(name='test', password='right_pass')
ok_(User.get(User.name == 'test').verify_password('right_pass'))
示例12: test_user_unique_name
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_unique_name(self):
User.create(name='test', password='pass')
with self.assertRaises(IntegrityError):
User.create(name='test', password='plusPass')
示例13: test_user_removal
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def test_user_removal(self):
newUser = User.create(name='test', password='pass')
newUser.delete_instance()
eq_(User.select().count(), 0)
示例14: add_user
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import create [as 别名]
def add_user(name, password):
try:
return User.create(name=name, password=password)
except IntegrityError:
raise ConflictException("user with the same name already exists")