diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2012-08-19 00:22:42 +1200 | 
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2012-08-19 00:22:42 +1200 | 
| commit | 60659a89c38cdbae3f7163d46aab12f49261ab6a (patch) | |
| tree | 8668a13c47b6f1f3e5adf3400f68be3868c61804 | |
| parent | 1b7990897e57df2d095e6eb06aa6c27bc81195ba (diff) | |
| download | mitmproxy-60659a89c38cdbae3f7163d46aab12f49261ab6a.tar.gz mitmproxy-60659a89c38cdbae3f7163d46aab12f49261ab6a.tar.bz2 mitmproxy-60659a89c38cdbae3f7163d46aab12f49261ab6a.zip | |
Little bit of love for the unit tests.
| -rw-r--r-- | test/test_cmdline.py | 14 | ||||
| -rw-r--r-- | test/test_dump.py | 6 | 
2 files changed, 19 insertions, 1 deletions
| diff --git a/test/test_cmdline.py b/test/test_cmdline.py index 0a1d6e8f..e1c5c88d 100644 --- a/test/test_cmdline.py +++ b/test/test_cmdline.py @@ -36,7 +36,7 @@ def test_parse_replace_hook():  def test_parse_setheaders(): -    x = cmdline.parse_replace_hook("/foo/bar/voing") +    x = cmdline.parse_setheader("/foo/bar/voing")      assert x == ("foo", "bar", "voing") @@ -53,6 +53,18 @@ def test_common():      assert v["stickycookie"] == "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"]      v = cmdline.get_common_options(opts)      assert v["replacements"] == [("foo", "bar", "voing")] diff --git a/test/test_dump.py b/test/test_dump.py index 884a5b64..0337bb33 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -99,6 +99,12 @@ class TestDumpMaster:          f = self._cycle(m, "content")          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):          for i in (1, 2, 3):              assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i, eventlog=True) | 
