예제 #1
0
 def testNamingFieldAppendRejectsBad(self):
   f = policy_simple.NamingField('RFC1918')
   bads = (
       'corp_internal',
       'CORP+INTERNAL',
   )
   for bad in bads:
     logging.debug('Testing bad "%s".', bad)
     self.assertRaises(ValueError, f.Append, bad)
예제 #2
0
 def testNamingFieldAcceptsGood(self):
   goods = (
       'CORP_INTERNAL',
       'RFC1918',
       'FOO_BAR102.BAZ101',
   )
   for good in goods:
     try:
       logging.debug('Testing good "%s".', good)
       _ = policy_simple.NamingField(good)
     except ValueError:
       self.fail('Rejected good NamingField value "%s".' % good)
예제 #3
0
 def testNamingFieldDedupes(self):
   f = policy_simple.NamingField('RFC1918 CORP_INTERNAL RFC1918')
   f.Append('RFC1918')
   f.Append('CORP_INTERNAL RFC1918')
   self.assertEqual(set(['RFC1918', 'CORP_INTERNAL']), f.value)
예제 #4
0
 def testNamingFieldStr(self):
   f = policy_simple.NamingField(' '.join(str(x) for x in xrange(25)))
   expected_str = ('UNKNOWN:: 0 1 10 11 12 13 14 15 16 17 18 19 2 20 21'
                   ' 22 23 24 3 4 5 6 7\n            9')
   self.assertEqual(expected_str, str(f))