Little bit of love for the unit tests.

This commit is contained in:
Aldo Cortesi 2012-08-19 00:22:42 +12:00
parent 1b7990897e
commit 60659a89c3
2 changed files with 19 additions and 1 deletions

View File

@ -36,7 +36,7 @@ def test_parse_replace_hook():
def test_parse_setheaders(): def test_parse_setheaders():
x = cmdline.parse_replace_hook("/foo/bar/voing") x = cmdline.parse_setheader("/foo/bar/voing")
assert x == ("foo", "bar", "voing") assert x == ("foo", "bar", "voing")
@ -53,6 +53,18 @@ def test_common():
assert v["stickycookie"] == "foo" assert v["stickycookie"] == "foo"
assert v["stickyauth"] == "foo" assert v["stickyauth"] == "foo"
opts.setheader = ["/foo/bar/voing"]
v = cmdline.get_common_options(opts)
assert v["setheaders"] == [("foo", "bar", "voing")]
opts.setheader = ["//"]
tutils.raises(
"empty clause",
cmdline.get_common_options,
opts
)
opts.setheader = []
opts.replace = ["/foo/bar/voing"] opts.replace = ["/foo/bar/voing"]
v = cmdline.get_common_options(opts) v = cmdline.get_common_options(opts)
assert v["replacements"] == [("foo", "bar", "voing")] assert v["replacements"] == [("foo", "bar", "voing")]

View File

@ -99,6 +99,12 @@ class TestDumpMaster:
f = self._cycle(m, "content") f = self._cycle(m, "content")
assert f.request.content == "foo" assert f.request.content == "foo"
def test_setheader(self):
o = dump.Options(setheaders=[(".*", "one", "two")])
m = dump.DumpMaster(None, o, None)
f = self._cycle(m, "content")
assert f.request.headers["one"] == ["two"]
def test_basic(self): def test_basic(self):
for i in (1, 2, 3): for i in (1, 2, 3):
assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i, eventlog=True) assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i, eventlog=True)