def test_unsubscribe_from_basket_task(self, unsubscribe_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(userprofile={'basket_token': 'foo'}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token, ['foo']) unsubscribe_mock.assert_called_with( user.userprofile.basket_token, user.email, newsletters=['foo'])
def test_unsubscribe_from_basket_task(self, unsubscribe_mock): user = UserFactory.create(userprofile={'basket_token': 'foo'}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token) unsubscribe_mock.assert_called_with(user.userprofile.basket_token, user.email, newsletters='newsletter')
def test_unsubscribe_from_basket_task_without_token(self, lookup_token_mock, basket_mock): lookup_token_mock.return_value = 'basket_token' basket_mock.lookup_user.return_value = {'token': 'basket_token'} user = UserFactory.create(userprofile={'basket_token': ''}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token) user = User.objects.get(pk=user.pk) # refresh data from DB basket_mock.unsubscribe.assert_called_with( 'basket_token', user.email, newsletters='newsletter')
def test_unsubscribe_from_basket_task(self, unsubscribe_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(userprofile={'basket_token': 'foo'}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token, ['foo']) unsubscribe_mock.assert_called_with(user.userprofile.basket_token, user.email, newsletters=['foo'])
def test_unsubscribe_from_basket_task_without_token( self, lookup_token_mock, basket_mock): lookup_token_mock.return_value = 'basket_token' basket_mock.lookup_user.return_value = {'token': 'basket_token'} user = UserFactory.create(userprofile={'basket_token': ''}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token) user = User.objects.get(pk=user.pk) # refresh data from DB basket_mock.unsubscribe.assert_called_with('basket_token', user.email, newsletters='newsletter')
def test_unsubscribe_from_basket_task(self, basket_mock, lookup_mock, unsubscribe_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(email='*****@*****.**') basket_mock.lookup_user.return_value = { 'email': user.email, # the old value 'token': 'token', 'newsletters': ['foo', 'bar'] } lookup_mock.reset_mock() unsubscribe_mock.reset_mock() with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, ['foo']) eq_(lookup_mock.subtask.call_count, 1) eq_(unsubscribe_mock.subtask.call_count, 1) lookup_mock.subtask.assert_called_with((user.email,)) unsubscribe_mock.subtask.called_with((['foo'],))
def test_unsubscribe_from_basket_task(self, basket_mock, lookup_mock, unsubscribe_mock, switch_is_active_mock): switch_is_active_mock.return_value = True user = UserFactory.create(email='*****@*****.**').userprofile basket_mock.lookup_user.return_value = { 'email': user.email, # the old value 'token': 'token', 'newsletters': ['foo', 'bar'] } lookup_mock.reset_mock() unsubscribe_mock.reset_mock() with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, ['foo']) eq_(lookup_mock.subtask.call_count, 1) eq_(unsubscribe_mock.subtask.call_count, 1) lookup_mock.subtask.assert_called_with((user.email,)) unsubscribe_mock.subtask.called_with((['foo'],))
def test_unsubscribe_from_basket_task(self, unsubscribe_mock): user = UserFactory.create(userprofile={'basket_token': 'foo'}) with patch('mozillians.users.tasks.BASKET_ENABLED', True): unsubscribe_from_basket_task(user.email, user.userprofile.basket_token) unsubscribe_mock.assert_called_with( user.userprofile.basket_token, user.email, newsletters='newsletter')