def test_write_values(self): tst = "foobarvoing" s = cStringIO.StringIO() rparse.write_values(s, [tst], []) assert s.getvalue() == tst for bs in range(1, len(tst) + 2): for off in range(len(tst)): s = cStringIO.StringIO() rparse.write_values(s, [tst], [(off, "disconnect")], blocksize=bs) assert s.getvalue() == tst[:off]
def test_write_values_inject(self): tst = "foo" s = cStringIO.StringIO() rparse.write_values(s, [tst], [(0, "inject", "aaa")], blocksize=5) assert s.getvalue() == "aaafoo" s = cStringIO.StringIO() rparse.write_values(s, [tst], [(1, "inject", "aaa")], blocksize=5) assert s.getvalue() == "faaaoo" s = cStringIO.StringIO() rparse.write_values(s, [tst], [(1, "inject", "aaa")], blocksize=5) assert s.getvalue() == "faaaoo"
def test_write_values_pauses(self): tst = "".join(str(i) for i in range(10)) for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, [tst], [(2, "pause", 0), (1, "pause", 0)], blocksize=i) assert s.getvalue() == tst for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, [tst], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == tst tst = ["".join(str(i) for i in range(10))]*5 for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, tst[:], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == "".join(tst)
def test_write_values_pauses(self): tst = "".join(str(i) for i in range(10)) for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, [tst], [(2, "pause", 0), (1, "pause", 0)], blocksize=i) assert s.getvalue() == tst for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, [tst], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == tst tst = ["".join(str(i) for i in range(10))] * 5 for i in range(2, 10): s = cStringIO.StringIO() rparse.write_values(s, tst[:], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == "".join(tst)
def test_write_values_disconnects(self): s = cStringIO.StringIO() tst = "foo"*100 rparse.write_values(s, [tst], [(0, "disconnect")], blocksize=5) assert not s.getvalue()
def test_write_values_disconnects(self): s = cStringIO.StringIO() tst = "foo" * 100 rparse.write_values(s, [tst], [(0, "disconnect")], blocksize=5) assert not s.getvalue()