當前位置: 首頁>>代碼示例>>Python>>正文


Python models.User類代碼示例

本文整理匯總了Python中social.tests.models.User的典型用法代碼示例。如果您正苦於以下問題:Python User類的具體用法?Python User怎麽用?Python User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tearDown

 def tearDown(self):
     self.strategy = None
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     HTTPretty.disable()
開發者ID:PublicInMotionGmbH,項目名稱:python-social-auth,代碼行數:7,代碼來源:open_id.py

示例2: test_multiple_accounts_with_same_email

 def test_multiple_accounts_with_same_email(self):
     user1 = User(username='foobar1')
     user2 = User(username='foobar2')
     user1.email = '[email protected]'
     user2.email = '[email protected]'
     self.do_login.when.called_with(after_complete_checks=False)\
         .should.throw(AuthException)
開發者ID:devvine,項目名稱:python-social-auth,代碼行數:7,代碼來源:pipeline_tests.py

示例3: test_multiple_accounts_with_same_email

 def test_multiple_accounts_with_same_email(self):
     user1 = User(username='foobar1')
     user2 = User(username='foobar2')
     user1.email = '[email protected]'
     user2.email = '[email protected]'
     with self.assertRaises(AuthException):
         self.do_login(after_complete_checks=False)
開發者ID:2070616d,項目名稱:TP3,代碼行數:7,代碼來源:test_pipeline.py

示例4: test_inactive_user

 def test_inactive_user(self):
     self.strategy.set_settings({
         'SOCIAL_AUTH_INACTIVE_USER_URL': '/inactive'
     })
     User.set_active(False)
     redirect = self.do_login(after_complete_checks=False)
     expect(redirect.url).to.equal('/inactive')
開發者ID:devvine,項目名稱:python-social-auth,代碼行數:7,代碼來源:login_test.py

示例5: setUp

 def setUp(self):
     HTTPretty.enable()
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     self.backend = module_member('social.backends.github.GithubOAuth2')
     self.strategy = TestStrategy(self.backend, TestStorage)
     self.user = None
開發者ID:0077cc,項目名稱:python-social-auth,代碼行數:9,代碼來源:actions.py

示例6: tearDown

 def tearDown(self):
     self.backend = None
     self.strategy = None
     self.user = None
     User.reset_cache()
     User.set_active(True)
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     HTTPretty.disable()
開發者ID:0077cc,項目名稱:python-social-auth,代碼行數:10,代碼來源:actions.py

示例7: setUp

 def setUp(self):
     HTTPretty.enable()
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     Backend = module_member("social.backends.github.GithubOAuth2")
     self.strategy = self.strategy or TestStrategy(TestStorage)
     self.backend = Backend(self.strategy, redirect_uri="/complete/github")
     self.user = None
開發者ID:humaneu,項目名稱:flask_app,代碼行數:10,代碼來源:actions.py

示例8: tearDown

 def tearDown(self):
     HTTPretty.disable()
     self.backend = None
     self.strategy = None
     self.name = None
     self.complete_url = None
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     TestCode.reset_cache()
開發者ID:relsi,項目名稱:w2p-social-auth,代碼行數:11,代碼來源:base.py

示例9: setUp

 def setUp(self):
     HTTPretty.enable()
     self.backend = module_member(self.backend_path)
     self.strategy = TestStrategy(self.backend, TestStorage)
     self.name = self.backend.name.upper().replace("-", "_")
     self.complete_url = self.strategy.build_absolute_uri(self.raw_complete_url.format(self.backend.name))
     backends = (self.backend_path, "social.tests.backends.test_broken.BrokenBackendAuth")
     self.strategy.set_settings({"SOCIAL_AUTH_AUTHENTICATION_BACKENDS": backends})
     self.strategy.set_settings(self.extra_settings())
     # Force backends loading to trash PSA cache
     load_backends(backends, force_load=True)
     User.reset_cache()
     TestUserSocialAuth.reset_cache()
     TestNonce.reset_cache()
     TestAssociation.reset_cache()
     TestCode.reset_cache()
開發者ID:relsi,項目名稱:w2p-social-auth,代碼行數:16,代碼來源:base.py

示例10: test_disconnect_with_partial_pipeline

    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,代碼行數:31,代碼來源:test_disconnect.py

示例11: test_disconnect_with_association_id

 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,代碼行數:10,代碼來源:test_disconnect.py

示例12: test_revoke_token

 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,代碼行數:11,代碼來源:test_dummy.py

示例13: test_user_persists_in_partial_pipeline

    def test_user_persists_in_partial_pipeline(self):
        user = User(username='foobar1')
        user.email = '[email protected]'

        self.strategy.set_settings({
            'SOCIAL_AUTH_PIPELINE': (
                'social.pipeline.social_auth.social_details',
                'social.pipeline.social_auth.social_uid',
                'social.pipeline.social_auth.associate_by_email',
                'social.tests.pipeline.set_user_from_args'
            )
        })

        redirect = self.do_login(after_complete_checks=False)

        # Handle the partial pipeline
        self.strategy.session_set('attribute', 'testing')

        data = self.strategy.session_pop('partial_pipeline')

        idx, backend, xargs, xkwargs = self.strategy.partial_from_session(data)

        self.backend.continue_pipeline(pipeline_index=idx,
                                              *xargs, **xkwargs)
開發者ID:cambridgemike,項目名稱:python-social-auth,代碼行數:24,代碼來源:test_pipeline.py

示例14: test_disconnect

 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,代碼行數:6,代碼來源:test_disconnect.py

示例15: test_not_allowed_to_disconnect

 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,代碼行數:6,代碼來源:test_disconnect.py


注:本文中的social.tests.models.User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。