Example #1
0
    def testIter(self):
        a = object()
        b = object()
        c = object()
        block = policy_simple.Block()
        block.fields = (a, b, c)

        self.assertEqual([a, b, c], list(block))
Example #2
0
    def testFieldsWithType(self):
        b = policy_simple.Block()
        c1 = policy_simple.Comment('test1')
        c2 = policy_simple.Comment('test2')
        d = policy_simple.DestinationAddress('XYZ')
        s = policy_simple.SourceAddress('ABC')
        for field in (c1, d, c2, s):
            b.AddField(field)

        self.assertEqual([c1, d, c2, s], b.fields)
        self.assertEqual([c1, c2], b.FieldsWithType(policy_simple.Comment))
Example #3
0
 def testRejectsNonField(self):
     b = policy_simple.Block()
     for t in ('', 3, lambda x: x, policy_simple.Header(),
               policy_simple.Policy('test')):
         self.assertRaises(TypeError, b.AddField, t)