diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-10-29 10:55:57 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-10-29 10:55:57 +1300 |
commit | 90e7142b5c8dd3ec9896e5308ea2e81a2d77d31d (patch) | |
tree | 3019934871c3ec64d131a2747e309b8c67aff07b /test | |
parent | 12a70d03ad721f6a137d118b65c11851ef7b96d7 (diff) | |
download | mitmproxy-90e7142b5c8dd3ec9896e5308ea2e81a2d77d31d.tar.gz mitmproxy-90e7142b5c8dd3ec9896e5308ea2e81a2d77d31d.tar.bz2 mitmproxy-90e7142b5c8dd3ec9896e5308ea2e81a2d77d31d.zip |
addons.View: better order reversal
Deal with some subtleties in order reversal, add a toggle method that emits
refresh.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_view.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index 527464ad..1ab7e8f4 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -62,16 +62,33 @@ def test_order(): v.set_order(view.key_request_method) assert [i.request.method for i in v] == ["GET", "GET", "PUT", "PUT"] - v.order_reverse = True + v.toggle_reversed() assert [i.request.method for i in v] == ["PUT", "PUT", "GET", "GET"] v.set_order(view.key_request_start) assert [i.request.timestamp_start for i in v] == [4, 3, 2, 1] - v.order_reverse = False + v.toggle_reversed() assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] +def test_reversed(): + v = view.View() + v.request(tft(start=1)) + v.request(tft(start=2)) + v.request(tft(start=3)) + v.toggle_reversed() + + assert v[0].request.timestamp_start == 3 + assert v[-1].request.timestamp_start == 1 + assert v[2].request.timestamp_start == 1 + tutils.raises(IndexError, v.__getitem__, 5) + tutils.raises(IndexError, v.__getitem__, -5) + + assert v.bisect(v[0]) == 1 + assert v.bisect(v[2]) == 3 + + def test_update(): v = view.View() flt = flowfilter.parse("~m get") |