本文整理汇总了Python中mozillians.users.models.UserProfile.lookup_basket_token方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.lookup_basket_token方法的具体用法?Python UserProfile.lookup_basket_token怎么用?Python UserProfile.lookup_basket_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.users.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.lookup_basket_token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lookup_token_exceptions
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import lookup_basket_token [as 别名]
def test_lookup_token_exceptions(self, mock_lookup_user):
# If basket raises any exception other than BASKET_UNKNOWN_EMAIL when
# we call lookup_basket_token, lookup_basket_token passes it up the chain
class SomeException(Exception):
pass
user = User(email='[email protected]')
profile = UserProfile(user=user)
mock_lookup_user.side_effect = SomeException
with self.assertRaises(SomeException):
profile.lookup_basket_token()
示例2: test_lookup_token_unregistered
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import lookup_basket_token [as 别名]
def test_lookup_token_unregistered(self, mock_lookup_user):
# Lookup token for a user with no registered email
# Basket raises unknown user exception, then lookup-token returns None
user = User(email="fak[email protected]")
profile = UserProfile(user=user)
mock_lookup_user.side_effect = basket.BasketException(code=basket.errors.BASKET_UNKNOWN_EMAIL)
result = profile.lookup_basket_token()
ok_(result is None)
示例3: test_lookup_token_registered
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import lookup_basket_token [as 别名]
def test_lookup_token_registered(self, mock_lookup_user):
# Lookup token for a user with registered email
# basket returns response with data, lookup_basket_token returns the token
user = User(email='[email protected]')
profile = UserProfile(user=user)
mock_lookup_user.return_value = {'status': 'ok', 'token': 'FAKETOKEN'}
result = profile.lookup_basket_token()
eq_('FAKETOKEN', result)