Allow a ListProperty of DictionaryProperties
parent
2d689815d7
commit
d08be151f7
|
@ -129,6 +129,8 @@ class ListProperty(Property):
|
|||
# constructor again
|
||||
result.append(valid)
|
||||
continue
|
||||
elif type(self.contained) is DictionaryProperty:
|
||||
obj_type = dict
|
||||
else:
|
||||
obj_type = self.contained
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from stix2 import EmailMIMEComponent, ExtensionsProperty, TCPExt
|
||||
from stix2 import CustomObject, EmailMIMEComponent, ExtensionsProperty, TCPExt
|
||||
from stix2.exceptions import AtLeastOnePropertyError, DictionaryKeyError
|
||||
from stix2.properties import (BinaryProperty, BooleanProperty,
|
||||
DictionaryProperty, EmbeddedObjectProperty,
|
||||
|
@ -266,6 +266,17 @@ def test_dictionary_property_invalid(d):
|
|||
assert str(excinfo.value) == d[1]
|
||||
|
||||
|
||||
def test_property_list_of_dictionary():
|
||||
@CustomObject('x-new-obj', [
|
||||
('property1', ListProperty(DictionaryProperty(), required=True)),
|
||||
])
|
||||
class NewObj():
|
||||
pass
|
||||
|
||||
test_obj = NewObj(property1=[{'foo': 'bar'}])
|
||||
assert test_obj.property1[0]['foo'] == 'bar'
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [
|
||||
{"sha256": "6db12788c37247f2316052e142f42f4b259d6561751e5f401a1ae2a6df9c674b"},
|
||||
[('MD5', '2dfb1bcc980200c6706feee399d41b3f'), ('RIPEMD-160', 'b3a8cd8a27c90af79b3c81754f267780f443dfef')],
|
||||
|
|
Loading…
Reference in New Issue