本文整理汇总了Python中streetsign_server.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类streetsign_server.models.User
的用法示例。
在下文中一共展示了User.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_admin_can_delete_user
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_can_delete_user(self):
self.login(ADMINNAME, ADMINPASS)
resp = self.post_delete_request()
self.assertEqual(resp.status_code, 200)
with self.assertRaises(User.DoesNotExist):
User.get(id=self.user2.id)
示例2: test_admin_needs_password_to_create_user
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_needs_password_to_create_user(self):
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
self.login(ADMINNAME, ADMINPASS)
resp = self.post_create_request()
self.assertIn("You need to enter your current password", resp.data)
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
示例3: test_admin_can_create_user
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_can_create_user(self):
# should not yet exist:
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
self.login(ADMINNAME, ADMINPASS)
resp = self.post_create_request(currpass=ADMINPASS)
self.assertEqual(resp.status_code, 200)
User.get(loginname="user2")
示例4: test_new_user_passwords_must_match
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_new_user_passwords_must_match(self):
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
self.login(ADMINNAME, ADMINPASS)
resp = self.post_create_request(currpass=ADMINPASS,
newpass='stuff',
conf_newpass='42')
self.assertIn("Passwords don't match", resp.data)
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
示例5: test_admin_can_unset_admin
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_can_unset_admin(self):
self.assertFalse(self.user.is_admin)
self.user.is_admin = True
self.user.save()
usernow = User.get(id=self.user.id)
self.assertTrue(usernow.is_admin)
self.login(ADMINNAME, ADMINPASS)
resp = self.post_update_request(userid=self.user.id, is_admin=False)
usernow = User.get(id=self.user.id)
self.assertFalse(usernow.is_admin)
示例6: test_cannot_have_empty_password
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_cannot_have_empty_password(self):
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
self.login(ADMINNAME, ADMINPASS)
resp = self.post_create_request(currpass=ADMINPASS,
newpass='',
conf_newpass='')
self.assertIn("Cannot Save", resp.data)
self.assertIn("passwordhash", resp.data)
with self.assertRaises(User.DoesNotExist):
User.get(loginname="user2")
示例7: test_admin_can_make_admin_with_on
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_can_make_admin_with_on(self):
self.assertFalse(self.user.is_admin)
self.login(ADMINNAME, ADMINPASS)
resp = self.post_update_request(userid=self.user.id, is_admin="on")
usernow = User.get(id=self.user.id)
self.assertTrue(usernow.is_admin)
示例8: test_emailaddress_must_be_valid
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_emailaddress_must_be_valid(self):
self.login(USERNAME, USERPASS)
resp = self.post_update_request(emailaddress='BANANA!!!!')
self.assertIn('not a valid emailaddress', resp.data)
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.emailaddress, '[email protected]')
示例9: test_normal_user_cannot_unset_admin
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_normal_user_cannot_unset_admin(self):
self.login(USERNAME, USERPASS)
resp = self.post_update_request(userid=self.admin.id, is_admin=False)
self.assertEqual(resp.status_code, 403)
adminnow = User.get(id=self.admin.id)
self.assertEqual(adminnow.is_admin, True)
示例10: test_cannot_set_own_groups
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_cannot_set_own_groups(self):
g1 = self.create_group('g1')
self.assertEqual(self.user.groups(), [])
self.login(USERNAME, USERPASS)
self.post_update_request(userid=self.user.id, groups=[g1.id])
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.groups(), [])
示例11: test_admin_can_set_groups
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_admin_can_set_groups(self):
g1 = self.create_group('g1')
self.assertEqual(self.user.groups(), [])
self.login(ADMINNAME, ADMINPASS)
self.post_update_request(userid=self.user.id, groups=[g1.id])
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.groups(), [g1])
示例12: test_cannot_have_matching_usernames
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_cannot_have_matching_usernames(self):
user2 = User(loginname='user2',
emailaddress='[email protected]',
is_admin=False)
user2.set_password(USERPASS)
user2.save()
# if this get works, then the user exists:
usernow = User.get(loginname="user2")
self.assertEqual(user2.id, usernow.id)
self.login(ADMINNAME, ADMINPASS)
resp = self.post_create_request(currpass=ADMINPASS,
newpass='not42', conf_newpass='not42')
self.assertIn("Username already exists", resp.data)
# and just make sure we didn't delete them, or set their password...
usernew = User.get(loginname="user2")
self.assertEqual(usernow.passwordhash, usernew.passwordhash)
示例13: test_normal_user_cannot_set_other_to_admin
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_normal_user_cannot_set_other_to_admin(self):
user2 = User(loginname="user2",
emailaddress='[email protected]',
is_admin=False)
user2.set_password("userpass2")
user2.save()
self.login(USERNAME, USERPASS)
resp = self.post_update_request(userid=user2.id, is_admin=True)
self.assertEqual(resp.status_code, 403)
usernow = User.get(id=user2.id)
self.assertEqual(usernow.is_admin, False)
示例14: test_logged_out_cannot_set_password
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_logged_out_cannot_set_password(self):
with self.ctx():
resp = self.client.post(url_for('user_edit', userid=self.user.id),
data={"action":"update",
"newpass": "200",
"conf_newpass": "200"},
follow_redirects=True)
self.assertIn("Permission Denied", resp.data)
# and make sure the password didn't get changed!
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.passwordhash, self.user.passwordhash)
示例15: test_cannot_change_password_without_current_password
# 需要导入模块: from streetsign_server.models import User [as 别名]
# 或者: from streetsign_server.models.User import get [as 别名]
def test_cannot_change_password_without_current_password(self):
self.login(USERNAME, USERPASS)
with self.ctx():
resp = self.client.post(url_for('user_edit', userid=self.user.id),
data={"action":"update",
"newpass": "200",
"conf_newpass": "200"},
follow_redirects=True)
self.assertNotIn("Password changed", resp.data)
self.assertIn("You need to enter your current password", resp.data)
usernow = User.get(id=self.user.id)
self.assertEqual(usernow.passwordhash, self.user.passwordhash)