Fix some TAXII DataStore tests

master
Chris Lenk 2020-04-03 15:58:56 -04:00
parent 9145bdf5e8
commit c7fb79d195
3 changed files with 15 additions and 8 deletions

View File

@ -4,7 +4,8 @@ from medallion.filters.basic_filter import BasicFilter
import pytest import pytest
from requests.models import Response from requests.models import Response
import six import six
from taxii2client import Collection, _filter_kwargs_to_query_params from taxii2client import Collection
from taxii2client.common import _filter_kwargs_to_query_params
import stix2 import stix2
from stix2.datastore import DataSourceError from stix2.datastore import DataSourceError
@ -38,7 +39,8 @@ class MockTAXIICollectionEndpoint(Collection):
self.objects, self.objects,
("id", "type", "version"), ("id", "type", "version"),
[], [],
) None,
)[0]
if objs: if objs:
return stix2.v20.Bundle(objects=objs) return stix2.v20.Bundle(objects=objs)
else: else:
@ -59,7 +61,8 @@ class MockTAXIICollectionEndpoint(Collection):
objects, objects,
("version",), ("version",),
[], [],
) None,
)[0]
else: else:
filtered_objects = [] filtered_objects = []
if filtered_objects: if filtered_objects:

View File

@ -4,7 +4,8 @@ from medallion.filters.basic_filter import BasicFilter
import pytest import pytest
from requests.models import Response from requests.models import Response
import six import six
from taxii2client import Collection, _filter_kwargs_to_query_params from taxii2client import Collection
from taxii2client.common import _filter_kwargs_to_query_params
import stix2 import stix2
from stix2.datastore import DataSourceError from stix2.datastore import DataSourceError
@ -38,8 +39,10 @@ class MockTAXIICollectionEndpoint(Collection):
self.objects, self.objects,
("id", "type", "version"), ("id", "type", "version"),
[], [],
) None,
)[0]
if objs: if objs:
print(objs)
return stix2.v21.Bundle(objects=objs) return stix2.v21.Bundle(objects=objs)
else: else:
resp = Response() resp = Response()
@ -59,7 +62,8 @@ class MockTAXIICollectionEndpoint(Collection):
objects, objects,
("version",), ("version",),
[], [],
) None,
)[0]
else: else:
filtered_objects = [] filtered_objects = []
if filtered_objects: if filtered_objects:

View File

@ -8,11 +8,11 @@ deps =
pytest pytest
pytest-cov pytest-cov
coverage coverage
taxii2-client<1.0.0 taxii2-client
fuzzywuzzy fuzzywuzzy
haversine haversine
python-Levenshtein python-Levenshtein
medallion<2.0.0 medallion
commands = commands =
python -m pytest --cov=stix2 stix2/test/ --cov-report term-missing -W ignore::stix2.exceptions.STIXDeprecationWarning python -m pytest --cov=stix2 stix2/test/ --cov-report term-missing -W ignore::stix2.exceptions.STIXDeprecationWarning