From e48e0886a8741746a9cfad2ef160a5f3fd43fb9c Mon Sep 17 00:00:00 2001 From: Chris Lenk Date: Mon, 19 Mar 2018 17:41:16 -0400 Subject: [PATCH] Improve code coverage slightly Environment will always have a CompositeDataSource, so the try/catches in add_filter/s did not make sense. --- stix2/environment.py | 10 ++-------- stix2/test/test_workbench.py | 4 ++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/stix2/environment.py b/stix2/environment.py index 69a394f..9f55a7e 100644 --- a/stix2/environment.py +++ b/stix2/environment.py @@ -156,16 +156,10 @@ class Environment(DataStoreMixin): set_default_object_marking_refs.__doc__ = ObjectFactory.set_default_object_marking_refs.__doc__ def add_filters(self, *args, **kwargs): - try: - return self.source.filters.update(*args, **kwargs) - except AttributeError: - raise AttributeError('Environment has no data source') + return self.source.filters.update(*args, **kwargs) def add_filter(self, *args, **kwargs): - try: - return self.source.filters.add(*args, **kwargs) - except AttributeError: - raise AttributeError('Environment has no data source') + return self.source.filters.add(*args, **kwargs) def parse(self, *args, **kwargs): return _parse(*args, **kwargs) diff --git a/stix2/test/test_workbench.py b/stix2/test/test_workbench.py index a8edfbc..13aad23 100644 --- a/stix2/test/test_workbench.py +++ b/stix2/test/test_workbench.py @@ -193,6 +193,10 @@ def test_workbench_related_with_filters(): assert resp[0].name == malware.name assert resp[0].created_by_ref == IDENTITY_ID + # filters arg can also be single filter + resp = get(MALWARE_ID).related(filters=filters[0]) + assert len(resp) == 1 + def test_add_data_source(): fs_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "stix2_data")