Merge pull request #605 from mfang90739/fix_issue_586
Fix constraint violation checking for GranularMarking in v21.main
commit
b2bbaeee06
|
@ -170,6 +170,18 @@ def test_granular_example_with_bad_selector():
|
||||||
assert str(excinfo.value) == "Invalid value for GranularMarking 'selectors': must adhere to selector syntax."
|
assert str(excinfo.value) == "Invalid value for GranularMarking 'selectors': must adhere to selector syntax."
|
||||||
|
|
||||||
|
|
||||||
|
def test_granular_marking_mutual_exclusion_error():
|
||||||
|
with pytest.raises(stix2.exceptions.MutuallyExclusivePropertiesError) as excinfo:
|
||||||
|
stix2.v21.GranularMarking(
|
||||||
|
lang="en",
|
||||||
|
marking_ref=stix2.TLP_GREEN,
|
||||||
|
selectors=["foo"],
|
||||||
|
)
|
||||||
|
assert excinfo.value.cls == stix2.v21.GranularMarking
|
||||||
|
assert excinfo.value.properties == ["lang", "marking_ref"]
|
||||||
|
assert 'are mutually exclusive' in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
def test_campaign_with_granular_markings_example():
|
def test_campaign_with_granular_markings_example():
|
||||||
campaign = stix2.v21.Campaign(
|
campaign = stix2.v21.Campaign(
|
||||||
id="campaign--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f",
|
id="campaign--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f",
|
||||||
|
|
|
@ -77,6 +77,7 @@ class GranularMarking(_STIXBase21):
|
||||||
def _check_object_constraints(self):
|
def _check_object_constraints(self):
|
||||||
super(GranularMarking, self)._check_object_constraints()
|
super(GranularMarking, self)._check_object_constraints()
|
||||||
self._check_at_least_one_property(['lang', 'marking_ref'])
|
self._check_at_least_one_property(['lang', 'marking_ref'])
|
||||||
|
self._check_mutually_exclusive_properties(['lang', 'marking_ref'])
|
||||||
|
|
||||||
|
|
||||||
class LanguageContent(_STIXBase21):
|
class LanguageContent(_STIXBase21):
|
||||||
|
|
Loading…
Reference in New Issue