From: Scott Worley Date: Thu, 23 Nov 2023 21:28:50 +0000 (-0800) Subject: fetch: Verify caching across sessions X-Git-Url: http://git.scottworley.com/paperdoorknob/commitdiff_plain/de7251fc8787f9634643d6d4e05cb3233682c34c fetch: Verify caching across sessions --- diff --git a/README.md b/README.md index 9782d63..e236b64 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ A polite glowfic → printable book scraper. * Retrieves glowfic +* Minimizes server load with local caching ### Alternatives diff --git a/paperdoorknob_test.py b/paperdoorknob_test.py index e966a6b..cb70ac5 100644 --- a/paperdoorknob_test.py +++ b/paperdoorknob_test.py @@ -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):