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


Python User.get方法代码示例

本文整理汇总了Python中social.tests.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在social.tests.models.User的用法示例。


在下文中一共展示了User.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_disconnect_with_partial_pipeline

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
    def test_disconnect_with_partial_pipeline(self):
        self.strategy.set_settings({
            'SOCIAL_AUTH_DISCONNECT_PIPELINE': (
                'social.pipeline.partial.save_status_to_session',
                'social.tests.pipeline.ask_for_password',
                'social.tests.pipeline.set_password',
                'social.pipeline.disconnect.allowed_to_disconnect',
                'social.pipeline.disconnect.get_entries',
                'social.pipeline.disconnect.revoke_tokens',
                'social.pipeline.disconnect.disconnect'
            )
        })
        self.do_login()
        user = User.get(self.expected_username)
        redirect = do_disconnect(self.backend, user)

        url = self.strategy.build_absolute_uri('/password')
        expect(redirect.url).to.equal(url)
        HTTPretty.register_uri(HTTPretty.GET, redirect.url, status=200,
                               body='foobar')
        HTTPretty.register_uri(HTTPretty.POST, redirect.url, status=200)

        password = 'foobar'
        requests.get(url)
        requests.post(url, data={'password': password})
        data = parse_qs(HTTPretty.last_request.body)
        expect(data['password']).to.equal(password)
        self.strategy.session_set('password', data['password'])

        redirect = do_disconnect(self.backend, user)
        expect(len(user.social)).to.equal(0)
开发者ID:Akanksha18,项目名称:Amipool,代码行数:33,代码来源:test_disconnect.py

示例2: test_disconnect_with_association_id

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
 def test_disconnect_with_association_id(self):
     self.do_login()
     user = User.get(self.expected_username)
     user.password = 'password'
     association_id = user.social[0].id
     second_usa = TestUserSocialAuth(user, user.social[0].provider, "uid2")
     self.assertEqual(len(user.social), 2)
     do_disconnect(self.backend, user, association_id)
     self.assertEqual(len(user.social), 1)
     self.assertEqual(user.social[0], second_usa)
开发者ID:2070616d,项目名称:TP3,代码行数:12,代码来源:test_disconnect.py

示例3: test_revoke_token

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
 def test_revoke_token(self):
     self.strategy.set_settings({
         'SOCIAL_AUTH_REVOKE_TOKENS_ON_DISCONNECT': True
     })
     self.do_login()
     user = User.get(self.expected_username)
     user.password = 'password'
     HTTPretty.register_uri(self._method(self.backend.REVOKE_TOKEN_METHOD),
                            self.backend.REVOKE_TOKEN_URL,
                            status=200)
     do_disconnect(self.backend, user)
开发者ID:2070616d,项目名称:TP3,代码行数:13,代码来源:test_dummy.py

示例4: test_disconnect

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
 def test_disconnect(self):
     self.do_login()
     user = User.get(self.expected_username)
     user.password = 'password'
     do_disconnect(self.backend, user)
     expect(len(user.social)).to.equal(0)
开发者ID:Akanksha18,项目名称:Amipool,代码行数:8,代码来源:test_disconnect.py

示例5: test_not_allowed_to_disconnect

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
 def test_not_allowed_to_disconnect(self):
     self.do_login()
     user = User.get(self.expected_username)
     do_disconnect.when.called_with(self.backend, user).should.throw(
         NotAllowedToDisconnect
     )
开发者ID:Akanksha18,项目名称:Amipool,代码行数:8,代码来源:test_disconnect.py

示例6: test_not_allowed_to_disconnect

# 需要导入模块: from social.tests.models import User [as 别名]
# 或者: from social.tests.models.User import get [as 别名]
 def test_not_allowed_to_disconnect(self):
     self.do_login()
     user = User.get(self.expected_username)
     with self.assertRaises(NotAllowedToDisconnect):
         do_disconnect(self.backend, user)
开发者ID:2070616d,项目名称:TP3,代码行数:7,代码来源:test_disconnect.py


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