Make sure custom properties are returned by object. closes #85
parent
134267bfd6
commit
6deaddc04e
|
@ -40,7 +40,14 @@ class _STIXBase(collections.Mapping):
|
|||
"""Base class for STIX object types"""
|
||||
|
||||
def object_properties(self):
|
||||
return list(self._properties.keys())
|
||||
props = set(self._properties.keys())
|
||||
custom_props = list(set(self._inner.keys()) - props)
|
||||
custom_props.sort()
|
||||
|
||||
all_properties = list(self._properties.keys())
|
||||
all_properties.extend(custom_props) # Any custom properties to the bottom
|
||||
|
||||
return all_properties
|
||||
|
||||
def _check_property(self, prop_name, prop, kwargs):
|
||||
if prop_name not in kwargs:
|
||||
|
|
|
@ -91,6 +91,7 @@ def test_custom_property_in_bundled_object():
|
|||
bundle = stix2.Bundle(identity, allow_custom=True)
|
||||
|
||||
assert bundle.objects[0].x_foo == "bar"
|
||||
assert '"x_foo": "bar"' in str(bundle)
|
||||
|
||||
|
||||
@stix2.sdo.CustomObject('x-new-type', [
|
||||
|
|
Loading…
Reference in New Issue