def default_addons(): return [ anticache.AntiCache(), anticomp.AntiComp(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), script.ScriptLoader(), filestreamer.FileStreamer(), replace.Replace(), setheaders.SetHeaders(), ]
def test_simple(self): s = state.State() o = options.Options(scripts=[]) m = master.FlowMaster(o, None, s) sc = script.ScriptLoader() m.addons.add(sc) assert len(m.addons) == 1 o.update( scripts=[tutils.test_data.path("data/addonscripts/recorder.py")]) assert len(m.addons) == 2 o.update(scripts=[]) assert len(m.addons) == 1
def default_addons(): return [ anticache.AntiCache(), anticomp.AntiComp(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), script.ScriptLoader(), filestreamer.FileStreamer(), # replace.Replace(), setheaders.SetHeaders(), serverplayback.ServerPlayback(), clientplayback.ClientPlayback(), ]
def test_simple(self): o = options.Options(scripts=[]) m = master.Master(o, proxy.DummyServer()) sc = script.ScriptLoader() m.addons.add(sc) assert len(m.addons) == 1 o.update( scripts = [ tutils.test_data.path("data/addonscripts/recorder.py") ] ) assert len(m.addons) == 2 o.update(scripts = []) assert len(m.addons) == 1
def test_order(self): rec = tutils.test_data.path("data/addonscripts/recorder.py") s = state.State() o = options.Options( scripts = [ "%s %s" % (rec, "a"), "%s %s" % (rec, "b"), "%s %s" % (rec, "c"), ] ) m = mastertest.RecordingMaster(o, None, s) sc = script.ScriptLoader() m.addons.add(sc) debug = [(i[0], i[1]) for i in m.event_log if i[0] == "debug"] assert debug == [ ('debug', 'a start'), ('debug', 'a configure'), ('debug', 'b start'), ('debug', 'b configure'), ('debug', 'c start'), ('debug', 'c configure') ] m.event_log[:] = [] o.scripts = [ "%s %s" % (rec, "c"), "%s %s" % (rec, "a"), "%s %s" % (rec, "b"), ] debug = [(i[0], i[1]) for i in m.event_log if i[0] == "debug"] assert debug == [ ('debug', 'c configure'), ('debug', 'a configure'), ('debug', 'b configure'), ] m.event_log[:] = [] o.scripts = [ "%s %s" % (rec, "x"), "%s %s" % (rec, "a"), ] debug = [(i[0], i[1]) for i in m.event_log if i[0] == "debug"] assert debug == [ ('debug', 'c done'), ('debug', 'b done'), ('debug', 'x start'), ('debug', 'x configure'), ('debug', 'a configure'), ]
def test_run_once(self): s = state.State() o = options.Options(scripts=[]) m = master.FlowMaster(o, None, s) sl = script.ScriptLoader() m.addons.add(o, sl) f = tutils.tflow(resp=True) with m.handlecontext(): sc = sl.run_once( tutils.test_data.path("data/addonscripts/recorder.py"), [f]) evts = [i[1] for i in sc.ns.call_log] assert evts == [ 'start', 'request', 'responseheaders', 'response', 'done' ] with m.handlecontext(): tutils.raises("file not found", sl.run_once, "nonexistent", [f])
def test_dupes(self): s = state.State() o = options.Options(scripts=["one", "one"]) m = master.FlowMaster(o, None, s) sc = script.ScriptLoader() tutils.raises(exceptions.OptionsError, m.addons.add, o, sc)
def test_dupes(self): o = options.Options(scripts=["one", "one"]) m = master.Master(o, proxy.DummyServer()) sc = script.ScriptLoader() tutils.raises(exceptions.OptionsError, m.addons.add, o, sc)