當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。