Used fixed property for Bundle spec_version

stix2.1
Greg Back 2017-02-24 10:50:43 -06:00
parent 2645bf2c71
commit 2768426a28
3 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,7 @@
"""STIX 2 Bundle object""" """STIX 2 Bundle object"""
from .base import _STIXBase from .base import _STIXBase
from .properties import IDProperty, TypeProperty from .properties import IDProperty, TypeProperty, Property
class Bundle(_STIXBase): class Bundle(_STIXBase):
@ -10,9 +10,7 @@ class Bundle(_STIXBase):
_properties = { _properties = {
'type': TypeProperty(_type), 'type': TypeProperty(_type),
'id': IDProperty(_type), 'id': IDProperty(_type),
'spec_version': { 'spec_version': Property(fixed="2.0"),
'fixed': "2.0",
},
'objects': {}, 'objects': {},
} }

View File

@ -68,7 +68,7 @@ class Property(object):
def validate(self, value): def validate(self, value):
try: try:
value = self.clean(value) value = self.clean(value)
except NotImplemetedError: except NotImplementedError:
pass pass
return value return value

View File

@ -471,7 +471,7 @@ def test_bundle_with_wrong_spec_version():
with pytest.raises(ValueError) as excinfo: with pytest.raises(ValueError) as excinfo:
bundle = stix2.Bundle(spec_version="1.2") bundle = stix2.Bundle(spec_version="1.2")
assert str(excinfo.value) == "Bundle must have spec_version='2.0'." assert str(excinfo.value) == "Invalid value for Bundle 'spec_version': must equal '2.0'."
def test_create_bundle(indicator, malware, relationship): def test_create_bundle(indicator, malware, relationship):