Exemple #1
0
    def test_remove_entity(self):
        i = indicator.Indicator()
        api.add_marking(i, MARKING)

        self.assertTrue(api.is_marked(i))
        api.remove_marking(i, MARKING)
        self.assertFalse(api.is_marked(i))
Exemple #2
0
    def test_clear_markings(self):
        i = indicator.Indicator()
        api.add_marking(i, MARKING)

        self.assertTrue(api.is_marked(i))
        api.clear_markings(i)
        self.assertEqual(False, api.is_marked(i))
Exemple #3
0
    def test_add_builtin(self):
        i = indicator.Indicator()
        i.id_ = "foo"

        marked = api.add_marking(i.id_, MARKING)
        self.assertEqual(marked, i.id_)
        self.assertTrue(api.is_marked(marked))
Exemple #4
0
    def test_remove_builtin(self):
        i = indicator.Indicator()
        i.id_ = "foo"

        i.id_ = api.add_marking(i.id_, MARKING)
        self.assertTrue(api.is_marked(i.id_))

        api.remove_marking(i.id_, MARKING)
        self.assertEqual(False, api.is_marked(i.id_))
Exemple #5
0
    def test_not_found(self):
        i = indicator.Indicator()
        api.add_marking(i, MARKING)

        self.assertRaises(
            KeyError,
            api.remove_marking,
            i,
            data_marking.MarkingSpecification()
        )
Exemple #6
0
    def test_remove_list(self):
        i = indicator.Indicator()
        i.alternative_id.append("foo")
        i.alternative_id.append("bar")

        _mark_list(i.alternative_id)

        self.assertTrue(all(api.is_marked(x) for x in i.alternative_id))

        for alt in i.alternative_id:
            api.remove_marking(alt, MARKING)

        self.assertEqual(False, all(api.is_marked(x) for x in i.alternative_id))
Exemple #7
0
    def test_add_list(self):
        i = indicator.Indicator()
        i.alternative_id.append("foo")
        i.alternative_id.append("bar")

        self.assertRaises(
            errors.UnmarkableError,
            api.add_marking,
            i.alternative_id,
            MARKING
        )

        _mark_list(i.alternative_id)

        self.assertEqual(i.alternative_id[0], "foo")
        self.assertEqual(i.alternative_id[1], "bar")

        self.assertTrue(api.is_marked(i.alternative_id[0]))
        self.assertTrue(api.is_marked(i.alternative_id[1]))
Exemple #8
0
    def test_is_not_marked(self):
        i = indicator.Indicator()
        self.assertFalse(api.is_marked(i))

        i.__datamarkings__ = None
        self.assertFalse(api.is_marked(i))
Exemple #9
0
 def test_is_marked(self):
     i = indicator.Indicator()
     i.__datamarkings__ = set([MARKING])
     self.assertTrue(api.is_marked(i))