From 204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 23 Jul 2012 10:47:33 +1200 Subject: Add function for effective length calculation when actions are present. --- test/test_rparse.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/test_rparse.py') diff --git a/test/test_rparse.py b/test/test_rparse.py index 23c9b3e6..0cb3e373 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -433,6 +433,36 @@ class TestResponse: testlen(rparse.parse_response({}, "400'msg':h'foo'='bar'")) testlen(rparse.parse_response({}, "400'msg':h'foo'='bar':b@100b")) + def test_effective_length(self): + def testlen(x, actions): + s = cStringIO.StringIO() + x.serve(s) + assert x.effective_length(actions) == len(s.getvalue()) + actions = [ + + ] + r = rparse.parse_response({}, "400'msg':b@100") + + actions = [ + (0, "disconnect"), + ] + r.actions = actions + testlen(r, actions) + + actions = [ + (0, "disconnect"), + (0, "inject", "foo") + ] + r.actions = actions + testlen(r, actions) + + actions = [ + (0, "inject", "foo") + ] + r.actions = actions + testlen(r, actions) + + def test_read_file(): tutils.raises(rparse.FileAccessDenied, rparse.read_file, {}, "=/foo") -- cgit v1.2.3