<br><br><div class="gmail_quote">On Wed, Nov 3, 2010 at 11:10 AM, Alex <span dir="ltr"><<a href="mailto:alex.lavoro.propio@gmail.com">alex.lavoro.propio@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I am developing an automated test in Python/Windows and I have to<br>
ensure certain HTTP requests are made and verify the GET parameters<br>
and responses. I need a tool to help me easily to capture and filter<br>
the HTTP requests.<br>
<br>
A typical test case is like:<br>
<br>
def setUp()<br>
self.capture = HttpCapture() # hypothetic<br>
def testFoo(self):<br>
self.capture.start("<a href="http://update.foobar.com" target="_blank">http://update.foobar.com</a>")<br>
subprocess.Popen(...)<br>
self.capture.end()<br>
# suppose self.capture.result() returns a list of strings,<br>
containing the URLs<br>
# have been visited betwen begin() and end()<br>
self.failUnless("<a href="http://update.foobar.com/" target="_blank">http://update.foobar.com/</a>" in<br>
self.capture.result() )<br>
<br>
It seems to me that it's not trivial to integrate 'pycap' into this<br>
picture. I wouldn't mind that the hypothetic HttpCatpure() launchs an<br>
external application. In fact, I did try to automate Wireshark by<br>
myself but it didn't seem to fit well into this test case design<br>
neither.<br>
<br></blockquote><div><br></div><div>There might be some existing tools for such task but off the top of my head, I would consider writing a simple module performing those requests either using httplib2 [1] if you know the URLs to be used. Or, in a case where it should act more like a browser and perform the requests transparently, use mechanize [2] or multi-mechanize.</div>
</div><div><br></div><div>[1] <a href="http://code.google.com/p/httplib2/">http://code.google.com/p/httplib2/</a></div><div>[2] <a href="http://wwwsearch.sourceforge.net/mechanize/">http://wwwsearch.sourceforge.net/mechanize/</a></div>
<div>[3] <a href="http://code.google.com/p/multi-mechanize/">http://code.google.com/p/multi-mechanize/</a></div><div><br></div>Hope that helps.<br>-- <br>- Sylvain<br><a href="http://www.defuze.org">http://www.defuze.org</a><br>
<a href="http://twitter.com/lawouach">http://twitter.com/lawouach</a><br>