Пример #1
0
 def testRangeListContains(self):
     """Check RangeList behavior as a container type."""
     r = acl.RangeList([1, (3, 6)])
     self.assertTrue(1 in r)
     self.assertTrue(5 in r)
     self.assertTrue(0 not in r)
     r = acl.RangeList([acl.TIP('10/8'), acl.TIP('172.16/12')])
     self.assertTrue(acl.TIP('10.1.1.1') in r)
     self.assertTrue(acl.TIP('192.168.1.1') not in r)
Пример #2
0
 def testMultipleConstants(self):
     """See if several discrete values are collapsed correctly."""
     r = acl.RangeList([5, 5, 5, 8, 9, 10])
     self.assertEqual(r, [5, (8, 10)])
Пример #3
0
 def testNonIncrementable(self):
     """Make sure non-incrementable values can be stored."""
     r = acl.RangeList(['y', 'x'])
     self.assertEqual(r, ['x', 'y'])
Пример #4
0
 def testOverlappingRangeAndInteger(self):
     """See if a single value that's also part of a range is elided."""
     r = acl.RangeList([(100, 199), 150])
     self.assertEqual(r, [(100, 199)])
Пример #5
0
 def testOverlappingRanges(self):
     """See if overlapping ranges are coalesced into one."""
     r = acl.RangeList([(100, 250), (200, 299)])
     self.assertEqual(r, [(100, 299)])
Пример #6
0
 def testAdjacentRanges(self):
     """See if adjacent ranges are coalesced into one."""
     r = acl.RangeList([(100, 199), (200, 299)])
     self.assertEqual(r, [(100, 299)])
Пример #7
0
 def testDuplicateProtocol(self):
     """Test duplicate protocols."""
     # Regression: These weren't suppresed because they are unique
     # objects, and so a Set can contain more than one of them.
     r = acl.RangeList([acl.Protocol(6), acl.Protocol(6)])
     self.assertEqual(r, [acl.Protocol(6)])
Пример #8
0
 def testDegenerateRange(self):
     """Make sure that the range x-x is the same as x."""
     r = acl.RangeList([(1024, 1024)])
     self.assertEqual(r, [1024])