From 17970a3faa9de3f1a983fa6ae7a05e823f5a3b83 Mon Sep 17 00:00:00 2001 From: Michael Chisholm Date: Tue, 27 Nov 2018 18:42:51 -0500 Subject: [PATCH] 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. --- stix2/test/test_datastore_filters.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/stix2/test/test_datastore_filters.py b/stix2/test/test_datastore_filters.py index 0f7b1ec..06a9a59 100644 --- a/stix2/test/test_datastore_filters.py +++ b/stix2/test/test_datastore_filters.py @@ -196,8 +196,8 @@ def test_apply_common_filters3(): assert len(resp) == 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 resp[0].id == real_stix_objs[0].id 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_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 resp = list(apply_common_filters(real_stix_objs, [filter_with_dt_obj])) assert len(resp) == 1