diff options
| author | Aldo Cortesi <aldo@corte.si> | 2018-06-17 09:20:34 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-17 09:20:34 +1200 |
| commit | 9ff4f55614eee729aede5aa45bca63026145b8ae (patch) | |
| tree | 392561b8a4ec3d2a7df32861d9aa1f32220600cf /test | |
| parent | 9113dabb32f3e9a966826c3394603a238b9cb1a3 (diff) | |
| parent | af54c260143f378bc71e3eba836544a59e9a2736 (diff) | |
| download | mitmproxy-9ff4f55614eee729aede5aa45bca63026145b8ae.tar.gz mitmproxy-9ff4f55614eee729aede5aa45bca63026145b8ae.tar.bz2 mitmproxy-9ff4f55614eee729aede5aa45bca63026145b8ae.zip | |
Merge pull request #3202 from madt1m/view-cleanup
View Cleanup - Initial steps
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/addons/test_view.py | 50 | ||||
| -rw-r--r-- | test/mitmproxy/test_command.py | 2 | ||||
| -rw-r--r-- | test/mitmproxy/test_types.py | 2 |
3 files changed, 35 insertions, 19 deletions
diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index bd724950..976c14b7 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -107,13 +107,12 @@ def test_simple(): def test_filter(): v = view.View() - f = flowfilter.parse("~m get") v.request(tft(method="get")) v.request(tft(method="put")) v.request(tft(method="get")) v.request(tft(method="put")) assert(len(v)) == 4 - v.set_filter(f) + v.set_filter_cmd("~m get") assert [i.request.method for i in v] == ["GET", "GET"] assert len(v._store) == 4 v.set_filter(None) @@ -124,6 +123,9 @@ def test_filter(): v.toggle_marked() assert len(v) == 4 + with pytest.raises(exceptions.CommandError): + v.set_filter_cmd("~notafilter regex") + v[1].marked = True v.toggle_marked() assert len(v) == 1 @@ -303,23 +305,26 @@ def test_setgetval(): def test_order(): v = view.View() - with taddons.context(v) as tctx: - v.request(tft(method="get", start=1)) - v.request(tft(method="put", start=2)) - v.request(tft(method="get", start=3)) - v.request(tft(method="put", start=4)) - assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] - - tctx.configure(v, view_order="method") - assert [i.request.method for i in v] == ["GET", "GET", "PUT", "PUT"] - v.set_reversed(True) - assert [i.request.method for i in v] == ["PUT", "PUT", "GET", "GET"] + v.request(tft(method="get", start=1)) + v.request(tft(method="put", start=2)) + v.request(tft(method="get", start=3)) + v.request(tft(method="put", start=4)) + assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] + + v.set_order("method") + assert v.get_order() == "method" + assert [i.request.method for i in v] == ["GET", "GET", "PUT", "PUT"] + v.set_reversed(True) + assert [i.request.method for i in v] == ["PUT", "PUT", "GET", "GET"] - tctx.configure(v, view_order="time") - assert [i.request.timestamp_start for i in v] == [4, 3, 2, 1] + v.set_order("time") + assert v.get_order() == "time" + assert [i.request.timestamp_start for i in v] == [4, 3, 2, 1] - v.set_reversed(False) - assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] + v.set_reversed(False) + assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] + with pytest.raises(exceptions.CommandError): + v.set_order("not_an_order") def test_reversed(): @@ -551,6 +556,17 @@ def test_settings(): assert not v.settings.keys() +def test_properties(): + v = view.View() + f = tft() + v.request(f) + assert v.get_length() == 1 + assert not v.get_marked() + v.toggle_marked() + assert v.get_length() == 0 + assert v.get_marked() + + def test_configure(): v = view.View() with taddons.context(v) as tctx: diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 029dbafd..d9dcf5f9 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -313,7 +313,7 @@ def test_typename(): class DummyConsole: - @command.command("view.resolve") + @command.command("view.flows.resolve") def resolve(self, spec: str) -> typing.Sequence[flow.Flow]: n = int(spec) return [tflow.tflow(resp=True)] * n diff --git a/test/mitmproxy/test_types.py b/test/mitmproxy/test_types.py index 35ff3241..571985fb 100644 --- a/test/mitmproxy/test_types.py +++ b/test/mitmproxy/test_types.py @@ -146,7 +146,7 @@ def test_strseq(): class DummyConsole: - @command.command("view.resolve") + @command.command("view.flows.resolve") def resolve(self, spec: str) -> typing.Sequence[flow.Flow]: if spec == "err": raise mitmproxy.exceptions.CommandError() |
