Remove dictionary/extension property non-empty req

Only bundle.objects and observed-data.objects have a requirement to
include at least one item.
master
Chris Lenk 2019-01-07 11:15:47 -05:00
parent 06e23b08b8
commit 2966efa4f0
5 changed files with 0 additions and 24 deletions

View File

@ -291,8 +291,6 @@ class DictionaryProperty(Property):
dictified = _get_dict(value)
except ValueError:
raise ValueError("The dictionary property must contain a dictionary")
if dictified == {}:
raise ValueError("The dictionary property must contain a non-empty dictionary")
for k in dictified.keys():
if self.spec_version == '2.0':
if len(k) < 3:
@ -498,8 +496,6 @@ class ExtensionsProperty(DictionaryProperty):
dictified = copy.deepcopy(dictified)
except ValueError:
raise ValueError("The extensions property must contain a dictionary")
if dictified == {}:
raise ValueError("The extensions property must contain a non-empty dictionary")
v = 'v' + self.spec_version.replace('.', '')

View File

@ -1140,15 +1140,6 @@ def test_process_example_windows_process_ext_empty():
assert excinfo.value.properties == sorted(properties_of_extension)
def test_process_example_extensions_empty():
with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo:
stix2.v20.Process(extensions={})
assert excinfo.value.cls == stix2.v20.Process
assert excinfo.value.prop_name == 'extensions'
assert 'non-empty dictionary' in excinfo.value.reason
def test_process_example_with_WindowsProcessExt_Object():
p = stix2.v20.Process(extensions={
"windows-process-ext": stix2.v20.WindowsProcessExt(

View File

@ -360,7 +360,6 @@ def test_dictionary_property_invalid_key(d):
@pytest.mark.parametrize(
"d", [
({}, "The dictionary property must contain a non-empty dictionary"),
# TODO: This error message could be made more helpful. The error is caused
# because `json.loads()` doesn't like the *single* quotes around the key
# name, even though they are valid in a Python dictionary. While technically

View File

@ -1114,15 +1114,6 @@ def test_process_example_windows_process_ext_empty():
assert excinfo.value.properties == sorted(properties_of_extension)
def test_process_example_extensions_empty():
with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo:
stix2.v21.Process(extensions={})
assert excinfo.value.cls == stix2.v21.Process
assert excinfo.value.prop_name == 'extensions'
assert 'non-empty dictionary' in excinfo.value.reason
def test_process_example_with_WindowsProcessExt_Object():
p = stix2.v21.Process(extensions={
"windows-process-ext": stix2.v21.WindowsProcessExt(

View File

@ -369,7 +369,6 @@ def test_dictionary_property_invalid_key(d):
@pytest.mark.parametrize(
"d", [
({}, "The dictionary property must contain a non-empty dictionary"),
# TODO: This error message could be made more helpful. The error is caused
# because `json.loads()` doesn't like the *single* quotes around the key
# name, even though they are valid in a Python dictionary. While technically