def test_remove_marking_mark_another_property_same_marking(self): after = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description"], "marking_ref": "marking-definition--1" }, ] } before = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description"], "marking_ref": "marking-definition--1" }, { "selectors": ["title"], "marking_ref": "marking-definition--1" } ] } api.remove_markings(before, ["title"], ["marking-definition--1"]) self.assertEqual(before, after)
def test_remove_marking_mark_one_selector_markings_from_multiple_ones(self): after = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description"], "marking_ref": "marking-definition--1" }, { "selectors": ["description", "title"], "marking_ref": "marking-definition--2" }, ] } before = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description", "title"], "marking_ref": "marking-definition--1" }, { "selectors": ["description", "title"], "marking_ref": "marking-definition--2" }, ] } api.remove_markings(before, ["title"], ["marking-definition--1"]) for m in before["granular_markings"]: self.assertTrue(m in after["granular_markings"])
def test_remove_marking_mark_one_selector_from_multiple_ones(self): after = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description"], "marking_ref": "marking-definition--1" }, ] } before = { "description": "test description", "title": "foo", "granular_markings": [ { "selectors": ["description", "title"], "marking_ref": "marking-definition--1" }, ] } api.remove_markings(before, ["title"], ["marking-definition--1"]) self.assertEqual(before, after)
def main(): file = open("campaign-marked.json") campaign = json.load(file) to_remove = api.get_markings(campaign, "title") api.remove_markings(campaign, "title", to_remove) print(json.dumps(campaign, indent=4, sort_keys=True))
def test_remove_markings_object_level(self): after = {"title": "test title", "description": "test description"} before = { "title": "test title", "description": "test description", "object_marking_refs": ["marking-definition--1"] } api.remove_markings(before, None, "marking-definition--1") self.assertEqual(before, after)
def test_remove_markings_multiple(self): after = { "title": "test title", "description": "test description", "object_marking_refs": ["marking-definition--2"] } before = { "title": "test title", "description": "test description", "object_marking_refs": [ "marking-definition--1", "marking-definition--2", "marking-definition--3" ] } api.remove_markings(before, None, ["marking-definition--1", "marking-definition--3"]) self.assertEqual(before, after)