def test_update_basket_token_existing_email(self, basket_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(vouched=False) basket_mock.lookup_user.return_value = {'token': 'example-token'} update_basket_token_task(user.userprofile.id) userprofile = UserProfile.objects.get(pk=user.userprofile.pk) eq_(userprofile.basket_token, 'example-token')
def test_update_basket_token_unknown_email(self, lookup_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(vouched=False, userprofile={'basket_token': 'example-token'}) eq_(user.userprofile.basket_token, 'example-token') def raise_basket_exception(*args, **kwargs): raise BasketException( 'foobar', code=BASKET_UNKNOWN_EMAIL, status_code=404) lookup_mock.side_effect = raise_basket_exception update_basket_token_task(user.userprofile.id) userprofile = UserProfile.objects.get(pk=user.userprofile.pk) eq_(userprofile.basket_token, '')
def test_update_basket_token_unknown_email(self, lookup_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create( vouched=False, userprofile={'basket_token': 'example-token'}) eq_(user.userprofile.basket_token, 'example-token') def raise_basket_exception(*args, **kwargs): raise BasketException('foobar', code=BASKET_UNKNOWN_EMAIL, status_code=404) lookup_mock.side_effect = raise_basket_exception update_basket_token_task(user.userprofile.id) userprofile = UserProfile.objects.get(pk=user.userprofile.pk) eq_(userprofile.basket_token, '')