diff --git a/stix2/test/test_properties.py b/stix2/test/test_properties.py index b8a589c..60a42e6 100644 --- a/stix2/test/test_properties.py +++ b/stix2/test/test_properties.py @@ -71,7 +71,9 @@ def test_property_fixed_and_required(): def test_list_property_property_type(): p = ListProperty(StringProperty) - assert p.clean(['abc', 'xyz'], False) + result = p.clean(['abc', 'xyz'], False) + assert result == (['abc', 'xyz'], False) + with pytest.raises(ValueError): p.clean([], False) @@ -89,7 +91,8 @@ def test_list_property_property_type_custom(): TestObj(foo="xyz"), ] - assert p.clean(objs_custom, True) + result = p.clean(objs_custom, True) + assert result == (objs_custom, True) with pytest.raises(CustomContentError): p.clean(objs_custom, False) @@ -99,7 +102,8 @@ def test_list_property_property_type_custom(): {"foo": "xyz"}, ] - assert p.clean(dicts_custom, True) + result = p.clean(dicts_custom, True) + assert result == (objs_custom, True) with pytest.raises(ExtraPropertiesError): p.clean(dicts_custom, False) @@ -114,10 +118,12 @@ def test_list_property_object_type(): p = ListProperty(TestObj) objs = [TestObj(foo="abc"), TestObj(foo="xyz")] - assert p.clean(objs, False) + result = p.clean(objs, False) + assert result == (objs, False) dicts = [{"foo": "abc"}, {"foo": "xyz"}] - assert p.clean(dicts, False) + result = p.clean(dicts, False) + assert result == (objs, False) def test_list_property_object_type_custom(): @@ -133,7 +139,8 @@ def test_list_property_object_type_custom(): TestObj(foo="xyz"), ] - assert p.clean(objs_custom, True) + result = p.clean(objs_custom, True) + assert result == (objs_custom, True) with pytest.raises(CustomContentError): p.clean(objs_custom, False) @@ -143,7 +150,8 @@ def test_list_property_object_type_custom(): {"foo": "xyz"}, ] - assert p.clean(dicts_custom, True) + result = p.clean(dicts_custom, True) + assert result == (objs_custom, True) with pytest.raises(ExtraPropertiesError): p.clean(dicts_custom, False) diff --git a/stix2/test/v20/test_properties.py b/stix2/test/v20/test_properties.py index 5c57ed0..af1ffec 100644 --- a/stix2/test/v20/test_properties.py +++ b/stix2/test/v20/test_properties.py @@ -16,6 +16,7 @@ from stix2.v20.common import MarkingProperty from . import constants + ID_PROP = IDProperty('my-type', spec_version="2.0") MY_ID = 'my-type--232c9d3f-49fc-4440-bb01-607f638778e7' diff --git a/stix2/test/v21/test_properties.py b/stix2/test/v21/test_properties.py index f963944..aa3624b 100644 --- a/stix2/test/v21/test_properties.py +++ b/stix2/test/v21/test_properties.py @@ -23,23 +23,6 @@ def test_dictionary_property(): p.clean({}) -def test_string_property(): - prop = StringProperty() - - assert prop.clean('foobar') - assert prop.clean(1) - assert prop.clean([1, 2, 3]) - - -def test_type_property(): - prop = TypeProperty('my-type') - - assert prop.clean('my-type') - with pytest.raises(ValueError): - prop.clean('not-my-type') - assert prop.clean(prop.default()) - - ID_PROP = IDProperty('my-type', spec_version="2.1") MY_ID = 'my-type--232c9d3f-49fc-4440-bb01-607f638778e7'