Unit test request replay thread.

This is a small patch, but is the culmination of lots of work: we can now unit
test the deep innards of mitmproxy, with coverage. There's a lot more to come
in this vein.
This commit is contained in:
Aldo Cortesi 2012-07-09 11:03:55 +12:00
parent e49c920d16
commit aab45078ad
2 changed files with 11 additions and 0 deletions

View File

@ -1382,6 +1382,7 @@ class FlowMaster(controller.Master):
self.masterq,
)
rt.start() # pragma: no cover
return rt
def run_script_hook(self, name, *args, **kwargs):
if self.script and not self.pause_scripts:

View File

@ -20,6 +20,16 @@ class SanityMixin:
def test_large(self):
assert len(self.pathod("200:b@50k").content) == 1024*50
def test_replay(self):
assert self.pathod("304").status_code == 304
assert len(self.master.state.view) == 1
l = self.master.state.view[0]
assert l.response.code == 304
l.request.path = "/p/305"
rt = self.master.replay_request(l)
rt.join()
assert l.response.code == 305
class TestHTTP(tutils.HTTPProxTest, SanityMixin):
def test_invalid_http(self):