On Sat, Dec 03, 2005 at 11:29:48AM -0500, Tres Seaver wrote:
Paul Winkler wrote: (snip)
... AcceleratedHTTPCacheManager has no test suite at all.
Erm. Actually it does; Tres added it on the TRUNK many months ago. I was looking at a 2.7 checkout! Mea culpa. However, the test suite currently *does* fire up an HTTP server (on a hardwired port, 1888). As I said, I'm not crazy about this, it seems needlessly fragile and makes the test code harder to read than I'd like. So I'm inclined to follow Tres' adapter suggestion, it seems like The Right Thing to me. I'll modify the existing suite accordingly on a branch. To the other respondents: Thanks for the suggestions, but I do not consider making AcceleratedHTTPCacheManager more flexible to be a "test turd". Tres outlined a real use case for changing the code (see below). I don't understand why you guys consider this more invasive than monkeypatching, which is capable of causing obscure breakage in far-flung tests. But thanks anyway.
You could modify the testing code do an adapter lookup for a component used to do the HTTP client stuff, and then arrange to register your dummy object in a test. I imagine that this would be useful for more than just testing; for instance, if I want to purge a whole tier of Squids, right now the only way to do that is to write a proxy-proxy (one version I wrote once was called PageAssassin) which distributes the PURGE request to them. An adapter-based scheme would allow me to replace the stock version with one which distributed the PURGE directly.
Tres.
-- Paul Winkler http://www.slinkp.com