Update with correct class name

Also PEP-8 fixes
stix2.1
Greg Back 2017-07-19 21:30:29 +00:00
parent bf9677094f
commit 55e92bc237
1 changed files with 20 additions and 17 deletions

View File

@ -2,19 +2,19 @@ from stix2.sources import taxii
def test_ds_taxii():
ds = taxii.TAXIIDataSource()
ds = taxii.TAXIICollectionSource()
assert ds.name == 'TAXII'
def test_ds_taxii_name():
ds = taxii.TAXIIDataSource(name='My Data Source Name')
ds = taxii.TAXIICollectionSource(name='My Data Source Name')
assert ds.name == "My Data Source Name"
def test_ds_params():
url = "http://taxii_url.com:5000"
creds = {"username": "Wade", "password": "Wilson"}
ds = taxii.TAXIIDataSource(api_root=url, auth=creds)
ds = taxii.TAXIICollectionSource(api_root=url, auth=creds)
assert ds.taxii_info['api_root']['url'] == url
assert ds.taxii_info['auth'] == creds
@ -55,12 +55,13 @@ def test_parse_taxii_filters():
"match[version]": "first"
}
ds = taxii.TAXIIDataSource()
ds = taxii.TAXIICollectionSource()
taxii_filters = ds._parse_taxii_filters(query)
assert taxii_filters == expected_params
def test_add_get_remove_filter():
class dummy(object):
@ -113,7 +114,7 @@ def test_add_get_remove_filter():
"Filter 'value' type is not supported. The type(value) must be python immutable type or dictionary"
]
ds = taxii.TAXIIDataSource()
ds = taxii.TAXIICollectionSource()
# add
ids, statuses = ds.add_filter(filters)
@ -133,8 +134,9 @@ def test_add_get_remove_filter():
# get
ds_filters = ds.get_filters()
# TODO: what are we trying to test here?
for idx, flt in enumerate(filters):
assert flt['value'] == filters[idx]['value']
assert flt['value'] == ds_filters[idx]['value']
# remove
ds.remove_filter([ids[3]])
@ -153,6 +155,7 @@ def test_add_get_remove_filter():
for id_ in rem_ids:
assert id_ in ids[:3]
def test_apply_common_filters():
stix_objs = [
{
@ -207,7 +210,7 @@ def test_apply_common_filters():
}
]
ds = taxii.TAXIIDataSource()
ds = taxii.TAXIICollectionSource()
resp = ds.apply_common_filters(stix_objs, [filters[0]])
ids = [r['id'] for r in resp]
@ -220,6 +223,7 @@ def test_apply_common_filters():
resp = ds.apply_common_filters(stix_objs, [filters[2]])
assert resp[0]['id'] == stix_objs[0]['id']
def test_deduplicate():
stix_objs = [
{
@ -284,7 +288,7 @@ def test_deduplicate():
}
]
ds = taxii.TAXIIDataSource()
ds = taxii.TAXIICollectionSource()
unique = ds.deduplicate(stix_objs)
# Only 3 objects are unique
@ -302,7 +306,6 @@ def test_deduplicate():
assert "2017-01-27T13:49:53.936Z" in mods
# def test_data_source_file():
# ds = file.FileDataSource()
#