'Ensure that after a cache miss, we fill the cache and can hit it.'

def test_request_cached_miss_and_then_hit(self):

    RequestCache.clear_request_cache()
    to_be_wrapped = Mock()
    to_be_wrapped.return_value = 42
    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()
    self.assertEqual(result, 42)
    self.assertEqual(to_be_wrapped.call_count, 1)
    result = wrapped()
    self.assertEqual(result, 42)
    self.assertEqual(to_be_wrapped.call_count, 1)
