当前位置: 首页>>代码示例>>Python>>正文


Python Session.refresh方法代码示例

本文整理汇总了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')
开发者ID:fakdora,项目名称:pyramid_simpleauth,代码行数:28,代码来源:tests.py

示例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)
开发者ID:fakdora,项目名称:pyramid_simpleauth,代码行数:30,代码来源:tests.py

示例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)
开发者ID:fakdora,项目名称:pyramid_simpleauth,代码行数:27,代码来源:tests.py

示例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")
开发者ID:malnoxon,项目名称:pyramid_simpleauth,代码行数:28,代码来源:tests.py

示例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)
开发者ID:malnoxon,项目名称:pyramid_simpleauth,代码行数:27,代码来源:tests.py

示例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)
开发者ID:malnoxon,项目名称:pyramid_simpleauth,代码行数:21,代码来源:tests.py

示例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)
开发者ID:fakdora,项目名称:pyramid_simpleauth,代码行数:25,代码来源:tests.py

示例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)
开发者ID:fakdora,项目名称:pyramid_simpleauth,代码行数:26,代码来源:tests.py


注:本文中的pyramid_basemodel.Session.refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。