]> git.scottworley.com Git - paperdoorknob/commitdiff
fetch: Verify caching across sessions
authorScott Worley <scottworley@scottworley.com>
Thu, 23 Nov 2023 21:28:50 +0000 (13:28 -0800)
committerScott Worley <scottworley@scottworley.com>
Wed, 20 Dec 2023 01:37:10 +0000 (17:37 -0800)
README.md
paperdoorknob_test.py

index 9782d630466c1246e8fb7a8aea9f9f53ac245775..e236b649fddbeb5a71569a09f320664d3cbb2d56 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
 A polite glowfic → printable book scraper.
 
 * Retrieves glowfic
 A polite glowfic → printable book scraper.
 
 * Retrieves glowfic
+* Minimizes server load with local caching
 
 
 ### Alternatives
 
 
 ### Alternatives
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)
 
             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):
     def testFetchErrors(self) -> None:
         with requests.session() as s:
             with self.assertRaises(requests.HTTPError):