X-Git-Url: http://git.scottworley.com/paperdoorknob/blobdiff_plain/705973e749e5a9da0453508dbd23de434a0fdc65..a5f4539c4cc5954515e1256289784f1b174a5a16:/fetch_test.py diff --git a/fetch_test.py b/fetch_test.py index 6bdf69e..5f21fee 100644 --- a/fetch_test.py +++ b/fetch_test.py @@ -5,8 +5,11 @@ # Free Software Foundation, version 3. +from io import StringIO import unittest + from requests import HTTPError + from testing.fakeserver import FakeGlowficServer from fetch import CachingFetcher, DirectFetcher @@ -40,6 +43,13 @@ class TestFetch(unittest.TestCase): f.fetch(f"http://localhost:{self._port}") self.assertEqual(self._server.request_count(), 1) + def testCacheHitRateReport(self) -> None: + buf = StringIO() + with CachingFetcher("testcachehitratereportwithcl", TIMEOUT, buf) as f: + for _ in range(7): + f.fetch(f"http://localhost:{self._port}") + self.assertEqual("Fetch cache hits: 6 (85.7%)\n", buf.getvalue()) + def testFetchErrors(self) -> None: with DirectFetcher(TIMEOUT) as f: with self.assertRaises(HTTPError):