Skip to content

Commit

Permalink
Add test for #128
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Haritonov committed Jun 25, 2019
1 parent 97287d1 commit 08cda14
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,17 @@ def test_remove_expired_entries(self, datetime_mock, datetime_mock2):
self.assertEqual(len(s.cache.keys_map), 0)
self.assertIn(ok_url, list(s.cache.responses.values())[0][0].url)

def test_cache_unpickle_errors(self):
url = httpbin('get?q=1')
self.assertFalse(self.s.get(url).from_cache)
with mock.patch("requests_cache.backends.base.BaseCache.restore_response", side_effect=TypeError):
resp = self.s.get(url)
self.assertFalse(resp.from_cache)
self.assertEquals(resp.json()["args"]["q"], "1")
resp = self.s.get(url)
self.assertTrue(resp.from_cache)
self.assertEquals(resp.json()["args"]["q"], "1")


if __name__ == '__main__':
unittest.main()

0 comments on commit 08cda14

Please sign in to comment.