]> git.scottworley.com Git - paperdoorknob/blobdiff - paperdoorknob_test.py
fetch: Verify caching across sessions
[paperdoorknob] / paperdoorknob_test.py
index e966a6b5b0385789b593566531e3ead27e1a49fd..cb70ac56dd214d26988a86e915aea762cb74008b 100644 (file)
@@ -73,6 +73,14 @@ class TestFetch(unittest.TestCase):
             paperdoorknob.fetch(f"http://localhost:{self._port()}", s, TIMEOUT)
             self.assertEqual(self._request_counter, 1)
 
+    def testFetchPersistentCaching(self) -> None:
+        with requests_cache.CachedSession() as s:
+            paperdoorknob.fetch(f"http://localhost:{self._port()}", s, TIMEOUT)
+            self.assertEqual(self._request_counter, 1)
+        with requests_cache.CachedSession() as s:
+            paperdoorknob.fetch(f"http://localhost:{self._port()}", s, TIMEOUT)
+            self.assertEqual(self._request_counter, 1)
+
     def testFetchErrors(self) -> None:
         with requests.session() as s:
             with self.assertRaises(requests.HTTPError):