Exemplo n.º 1
0
    def test_err(self):
        c = flow.State()
        req = tutils.treq()
        f = c.add_request(req)
        e = flow.Error(f.request, "message")
        assert c.add_error(e)

        e = flow.Error(tutils.tflow().request, "message")
        assert not c.add_error(e)

        c = flow.State()
        req = tutils.treq()
        f = c.add_request(req)
        e = flow.Error(f.request, "message")
        c.set_limit("~e")
        assert not c.view
        assert not c.view
        assert c.add_error(e)
        assert c.view
Exemplo n.º 2
0
    def test_client_playback(self):
        s = flow.State()

        f = tutils.tflow_full()
        pb = [tutils.tflow_full(), f]
        fm = flow.FlowMaster(None, s)
        assert not fm.start_server_playback(pb, False, [], False)
        assert not fm.start_client_playback(pb, False)

        q = Queue.Queue()
        assert not fm.state.flow_count()
        fm.tick(q)
        assert fm.state.flow_count()

        fm.handle_error(flow.Error(f.request, "error"))
Exemplo n.º 3
0
 def test_script(self):
     s = flow.State()
     fm = flow.FlowMaster(None, s)
     assert not fm.load_script("scripts/all.py")
     req = tutils.treq()
     fm.handle_clientconnect(req.client_conn)
     assert fm.script.ns["log"][-1] == "clientconnect"
     f = fm.handle_request(req)
     assert fm.script.ns["log"][-1] == "request"
     resp = tutils.tresp(req)
     fm.handle_response(resp)
     assert fm.script.ns["log"][-1] == "response"
     dc = flow.ClientDisconnect(req.client_conn)
     fm.handle_clientdisconnect(dc)
     assert fm.script.ns["log"][-1] == "clientdisconnect"
     err = flow.Error(f.request, "msg")
     fm.handle_error(err)
     assert fm.script.ns["log"][-1] == "error"
Exemplo n.º 4
0
    def test_all(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        fm.anticache = True
        fm.anticomp = True
        req = tutils.treq()
        fm.handle_clientconnect(req.client_conn)

        f = fm.handle_request(req)
        assert s.flow_count() == 1

        resp = tutils.tresp(req)
        fm.handle_response(resp)
        assert s.flow_count() == 1

        rx = tutils.tresp()
        assert not fm.handle_response(rx)

        dc = flow.ClientDisconnect(req.client_conn)
        fm.handle_clientdisconnect(dc)

        err = flow.Error(f.request, "msg")
        fm.handle_error(err)
Exemplo n.º 5
0
def tflow_err():
    r = treq()
    f = flow.Flow(r)
    f.error = flow.Error(r, "error")
    f.error.reply = controller.DummyReply()
    return f
Exemplo n.º 6
0
 def test_replace(self):
     e = flow.Error(None, "amoop")
     e.replace("moo", "bar")
     assert e.msg == "abarp"
Exemplo n.º 7
0
 def _add_error(self, state):
     req = tutils.treq()
     f = state.add_request(req)
     f.error = flow.Error(f.request, "msg")
Exemplo n.º 8
0
def tflow_err():
    r = treq()
    f = flow.Flow(r)
    f.error = flow.Error(r, "error")
    return f
Exemplo n.º 9
0
 def err(self):
     f = self.req()
     f.error = flow.Error(f.request, "msg")
     return f
Exemplo n.º 10
0
def terr(req=None):
    if not req:
        req = treq()
    err = flow.Error(req, "error")
    err.reply = controller.DummyReply()
    return err