'Ensure that calling a decorated function that returns None
properly caches the result and doesn\'t recall the underlying
function.'

def test_request_cached_with_none_result(self):

    RequestCache.clear_request_cache()
    to_be_wrapped = Mock()
    to_be_wrapped.side_effect = [None, None, None, 1, 1]
    self.assertEqual(to_be_wrapped.call_count, 0)
    def mock_wrapper(*args, **kwargs):
        'Simple    wrapper    to    let    us    decorate    our    mock.'
        return to_be_wrapped(*args, **kwargs)
    wrapped = request_cached(mock_wrapper)
    result = wrapped(1)
    self.assertEqual(result, None)
    self.assertEqual(to_be_wrapped.call_count, 1)
    result = wrapped(2)
    self.assertEqual(result, None)
    self.assertEqual(to_be_wrapped.call_count, 2)
    direct_result = mock_wrapper(3)
    self.assertEqual(direct_result, None)
    self.assertEqual(to_be_wrapped.call_count, 3)
    result = wrapped(1)
    self.assertEqual(result, None)
    self.assertEqual(to_be_wrapped.call_count, 3)
    result = wrapped(2)
    self.assertEqual(result, None)
    self.assertEqual(to_be_wrapped.call_count, 3)
