本文整理汇总了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()
示例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)
示例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)
示例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')
示例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
示例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()
示例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
示例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()
示例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()
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
)