def test_unsubscribe_user_task_success(self, unsubscribe_mock): result = { 'status': 'ok', 'newsletters': ['foo', 'bar', 'foobar'], 'email': '*****@*****.**', 'token': 'token' } unsubscribe_user_task(result, newsletters=['foo', 'bar']) unsubscribe_mock.assert_called_with(token='token', email='*****@*****.**', newsletters=['foo', 'bar'], optout=False)
def test_unsubscribe_user_basket_error(self, unsubscribe_mock, retry_mock): result = { 'status': 'ok', 'newsletters': ['foo', 'bar'], 'email': '*****@*****.**', 'token': 'token' } exc = BasketException(u'Error error error') unsubscribe_mock.side_effect = [exc, None] retry_mock.side_effect = Retry with self.assertRaises(Retry): unsubscribe_user_task(result, newsletters=['foo', 'bar']) retry_mock.called_with(exc)
def test_unsubscribe_user_no_result(self): ok_(not unsubscribe_user_task(result={}))