2011-02-16 09:10:24 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
import libpry
|
|
|
|
from libmproxy import dump
|
|
|
|
import utils
|
|
|
|
|
|
|
|
|
|
|
|
class uDumpMaster(libpry.AutoTree):
|
|
|
|
def _dummy_cycle(self, m):
|
|
|
|
req = utils.treq()
|
|
|
|
cc = req.client_conn
|
|
|
|
resp = utils.tresp(req)
|
|
|
|
m.handle_clientconnection(cc)
|
|
|
|
m.handle_request(req)
|
|
|
|
m.handle_response(resp)
|
|
|
|
|
2011-02-16 10:03:46 +00:00
|
|
|
def test_options(self):
|
|
|
|
o = dump.Options(verbosity = 2)
|
|
|
|
assert o.verbosity == 2
|
|
|
|
libpry.raises(AttributeError, dump.Options, nonexistent = 2)
|
|
|
|
|
2011-02-16 09:10:24 +00:00
|
|
|
def test_basic_verbosities(self):
|
|
|
|
for i in (1, 2, 3):
|
|
|
|
cs = StringIO()
|
2011-02-16 10:03:46 +00:00
|
|
|
o = dump.Options(
|
|
|
|
verbosity = i
|
|
|
|
)
|
|
|
|
m = dump.DumpMaster(None, o, cs)
|
2011-02-16 09:10:24 +00:00
|
|
|
self._dummy_cycle(m)
|
|
|
|
assert "GET" in cs.getvalue()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests = [
|
|
|
|
uDumpMaster()
|
|
|
|
]
|
|
|
|
|
|
|
|
|