Esempio n. 1
0
    def testParseTerm(self):
        parser = self.Parser('term testy {\ntarget::Test\n}')
        expected = policy_simple.Term('testy')
        expected.AddField(policy_simple.Target('Test'))

        pol = parser.Parse()
        self.assertEqual(expected, pol.members[0])
Esempio n. 2
0
    def testAddMember(self):
        p = policy_simple.Policy('test')
        good = [
            policy_simple.Header(),
            policy_simple.Term('test'),
            policy_simple.BlankLine(),
            policy_simple.CommentLine('test'),
            policy_simple.Include('other_pol')
        ]
        bad = ('', 3, lambda x: x, policy_simple.Field('test'))

        for member in good:
            try:
                p.AddMember(member)
            except TypeError:
                self.fail('Policy should accept member "%s"' % member)
        self.assertEqual(good, p.members)

        for member in bad:
            self.assertRaises(TypeError, p.AddMember, member)