From 6299ff9b38d6d6543930654a61bb4e27f7c00fcc Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Fri, 20 Sep 2024 15:54:41 -0400 Subject: [PATCH] Add v21 test for GranularMarking to close #586. --- stix2/test/v21/test_markings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stix2/test/v21/test_markings.py b/stix2/test/v21/test_markings.py index d3fd11b..4792549 100644 --- a/stix2/test/v21/test_markings.py +++ b/stix2/test/v21/test_markings.py @@ -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." +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(): campaign = stix2.v21.Campaign( id="campaign--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f",