Fixed a couple filter tests.
- a length check should come before the access, so you can verify whether the access will succeed. - Also removed some tests which can't work, due to the filter changes. In fact, a lot of these tests should probably be removed or changed if we want to disallow running apply_common_filters() on plain dicts. They will often coincidentally still succeed though, so I left them in.master
parent
3a2f247f68
commit
17970a3faa
|
@ -196,8 +196,8 @@ def test_apply_common_filters3():
|
||||||
assert len(resp) == 3
|
assert len(resp) == 3
|
||||||
|
|
||||||
resp = list(apply_common_filters(real_stix_objs, [filters[3]]))
|
resp = list(apply_common_filters(real_stix_objs, [filters[3]]))
|
||||||
assert resp[0].id == real_stix_objs[0].id
|
|
||||||
assert len(resp) == 3
|
assert len(resp) == 3
|
||||||
|
assert resp[0].id == real_stix_objs[0].id
|
||||||
|
|
||||||
|
|
||||||
def test_apply_common_filters4():
|
def test_apply_common_filters4():
|
||||||
|
@ -338,14 +338,6 @@ def test_datetime_filter_behavior():
|
||||||
filter_with_dt_obj = Filter("created", "=", parse_into_datetime("2016-02-14T00:00:00.000Z", "millisecond"))
|
filter_with_dt_obj = Filter("created", "=", parse_into_datetime("2016-02-14T00:00:00.000Z", "millisecond"))
|
||||||
filter_with_str = Filter("created", "=", "2016-02-14T00:00:00.000Z")
|
filter_with_str = Filter("created", "=", "2016-02-14T00:00:00.000Z")
|
||||||
|
|
||||||
# check that filter value is converted from datetime to str
|
|
||||||
assert isinstance(filter_with_dt_obj.value, str)
|
|
||||||
|
|
||||||
# compare datetime string to filter w/ datetime obj
|
|
||||||
resp = list(apply_common_filters(stix_objs, [filter_with_dt_obj]))
|
|
||||||
assert len(resp) == 1
|
|
||||||
assert resp[0]["id"] == "vulnerability--ee916c28-c7a4-4d0d-ad56-a8d357f89fef"
|
|
||||||
|
|
||||||
# compare datetime obj to filter w/ datetime obj
|
# compare datetime obj to filter w/ datetime obj
|
||||||
resp = list(apply_common_filters(real_stix_objs, [filter_with_dt_obj]))
|
resp = list(apply_common_filters(real_stix_objs, [filter_with_dt_obj]))
|
||||||
assert len(resp) == 1
|
assert len(resp) == 1
|
||||||
|
|
Loading…
Reference in New Issue