From de7251fc8787f9634643d6d4e05cb3233682c34c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 23 Nov 2023 13:28:50 -0800 Subject: [PATCH 1/1] fetch: Verify caching across sessions --- README.md | 1 + paperdoorknob_test.py | 8 ++++++++ 2 files changed, 9 insertions(+) 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): -- 2.44.1