Added tests for new primitives

This commit is contained in:
madt1m 2018-06-13 15:57:21 +02:00
parent da2365db4e
commit 40faf2c662
2 changed files with 28 additions and 17 deletions

View File

@ -292,7 +292,7 @@ class View(collections.Sequence):
# Filter
@command.command("view.filter.set")
def filter_set(self, f: str) -> None:
def set_filter_cmd(self, f: str) -> None:
"""
Sets the current view filter.
"""

View File

@ -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)
@ -303,23 +302,24 @@ 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]
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.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]
def test_reversed():
@ -551,6 +551,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: