Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Fix a broken test
Browse files Browse the repository at this point in the history
`test_update_cached_response_with_valid_headers` is wrong even though
it currently passes. As far as I can tell it attempts to emulate the
following scenario:
* There is already a cached response for `http://url.com/`
* `CacheController.update_cached_response` is called with a request and
a validation response for the same url
The problem is: it incorrectly sets the second url to `http://foo.com`.
This causes `CacheController.cache.get(cache_url)` to return None.
The test currently passes because `CacheController.serializer.loads`
is mocked and `CacheController.update_cached_response` currently passes
`CacheController.cache.get(cache_url)` to
`CacheController.serializer.loads` unconditionally:
```py
self.serializer.loads(request, self.cache.get(cache_url))
```

This test failed when I tried to refactor the code
  • Loading branch information
hexagonrecursion committed Feb 21, 2021
1 parent f511960 commit ccadca2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_update_cached_response_with_valid_headers(self):
# skip our in/out processing
cc.serializer = Mock()
cc.serializer.loads.return_value = cached_resp
cc.cache_url = Mock(return_value="http://foo.com")
cc.cache_url = Mock(return_value=self.url)

result = cc.update_cached_response(Mock(), resp)

Expand Down

0 comments on commit ccadca2

Please sign in to comment.