本文整理汇总了Python中pyramid_basemodel.Session.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python Session.refresh方法的具体用法?Python Session.refresh怎么用?Python Session.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid_basemodel.Session
的用法示例。
在下文中一共展示了Session.refresh方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sucess
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_sucess(self):
"If all conditions are met, change password"
# Create a user.
user = self.makeUser('thruflo', 'Password')
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {
'old_password': 'Password',
'new_password': 'sworDpas',
'new_confirm': 'sworDpas',
'next': '/foo/bar',
}
res = self.app.post('/auth/change_password', post_data)
# Verify that password has changed
Session.add(user)
Session.refresh(user)
self.assertNotEquals(user.password, old_hash)
# Verify redirect
self.assertEquals(res.headers['Location'], 'http://localhost/foo/bar')
示例2: test_success
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_success(self):
"Set preferred email address"
# Create user with email address
user = self.makeUserWithEmail()
# Add another one
user.emails.append(model.Email(address=u'[email protected]',
is_preferred=True))
model.save(user)
transaction.commit()
Session.add(user)
email1, email2 = user.emails
# Sanity check
self.assertNotEquals(user.preferred_email, email1)
self.assertEquals(user.preferred_email, email2)
# Attempt to make the address primary
self.authenticate()
self.app.post('/auth/prefer_email', {
'email_address': email1.address
})
# Verify that email is not the user's preferred email
Session.add(email1)
Session.refresh(email1)
self.assertEquals(user.preferred_email, email1)
self.assertNotEquals(user.preferred_email, email2)
示例3: test_wrong_old_password
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_wrong_old_password(self):
"No password change if old password is not corret"
# Create a user.
user = self.makeUser('thruflo', 'Password')
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {
'old_password': 'foobarbaz',
'new_password': 'swordpas',
'new_confirm': 'swordpas',
'next': '/foo/bar',
}
res = self.app.post('/auth/change_password', post_data)
# Verify that password hasn't changed
Session.add(user)
Session.refresh(user)
self.assertTrue("Wrong current password" in res.body)
self.assertTrue("/foo/bar" in res.body)
self.assertEquals(user.password, old_hash)
示例4: test_sucess
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_sucess(self):
"If all conditions are met, change password"
# Create a user.
user = self.makeUser("thruflo", "Password")
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {
"old_password": "Password",
"new_password": "sworDpas",
"new_confirm": "sworDpas",
"next": "/foo/bar",
}
res = self.app.post("/auth/change_password", post_data)
# Verify that password has changed
Session.add(user)
Session.refresh(user)
self.assertNotEquals(user.password, old_hash)
# Verify redirect
self.assertEquals(res.headers["Location"], "http://localhost/foo/bar")
示例5: test_wrong_old_password
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_wrong_old_password(self):
"No password change if old password is not corret"
# Create a user.
user = self.makeUser("thruflo", "Password")
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {
"old_password": "foobarbaz",
"new_password": "swordpas",
"new_confirm": "swordpas",
"next": "/foo/bar",
}
res = self.app.post("/auth/change_password", post_data)
# Verify that password hasn't changed
Session.add(user)
Session.refresh(user)
self.assertTrue("Wrong current password" in res.body)
self.assertTrue("/foo/bar" in res.body)
self.assertEquals(user.password, old_hash)
示例6: test_new_passwords_dont_match
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_new_passwords_dont_match(self):
"No password change if new passwords don't match"
# Create a user.
user = self.makeUser("thruflo", "Password")
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {"old_password": "Password", "new_password": "swordpas", "new_confirm": "oswdrpsa"}
res = self.app.post("/auth/change_password", post_data)
# Verify that password hasn't changed
Session.add(user)
Session.refresh(user)
self.assertTrue("Fields do not match" in res.body)
self.assertEquals(user.password, old_hash)
示例7: test_new_passwords_dont_match
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_new_passwords_dont_match(self):
"No password change if new passwords don't match"
# Create a user.
user = self.makeUser('thruflo', 'Password')
Session.add(user)
old_hash = user.password
self.authenticate()
# Attempt to change password.
post_data = {
'old_password': 'Password',
'new_password': 'swordpas',
'new_confirm': 'oswdrpsa',
}
res = self.app.post('/auth/change_password', post_data)
# Verify that password hasn't changed
Session.add(user)
Session.refresh(user)
self.assertTrue("Fields do not match" in res.body)
self.assertEquals(user.password, old_hash)
示例8: test_failure
# 需要导入模块: from pyramid_basemodel import Session [as 别名]
# 或者: from pyramid_basemodel.Session import refresh [as 别名]
def test_failure(self):
"Token is invalid, email address should not be confirmed"
# Create a user
user = self.makeUserWithEmail()
# Sanity check
self.assertFalse(user.emails[0].is_confirmed)
# Bogus attempts to confirm email address
# 1. malformed link
url = '/auth/confirm/foo'
res = self.app.get(url)
self.assertTrue('invalid' in res.body)
# 2. invalid token
email = user.emails[0]
url = self.makeConfirmationLink(email) + 'gibberish'
res = self.app.get(url)
self.assertTrue('invalid' in res.body)
# Verify that email address has been confirmed
Session.add(email)
Session.refresh(email)
self.assertFalse(email.is_confirmed)