Beispiel #1
0
 def test_get_shortened_ipv6_cidr(self):
     self.assertEqual(
         "2600::/64",
         utils.get_shortened_ipv6_cidr(
             "2600:0000:0000:0000:0000:0000:0000:0000/64"))
     self.assertEqual("2600::/64",
                      utils.get_shortened_ipv6_cidr("2600::1/64"))
     self.assertRaises(netaddr.AddrFormatError,
                       utils.get_shortened_ipv6_cidr, "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError,
                       utils.get_shortened_ipv6_cidr, "failure")
Beispiel #2
0
 def test_get_shortened_ipv6_cidr(self):
     self.assertEqual("2600::/64", utils.get_shortened_ipv6_cidr(
             "2600:0000:0000:0000:0000:0000:0000:0000/64"))
     self.assertEqual("2600::/64", utils.get_shortened_ipv6_cidr(
             "2600::1/64"))
     self.assertRaises(netaddr.AddrFormatError,
                       utils.get_shortened_ipv6_cidr,
                       "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError,
                       utils.get_shortened_ipv6_cidr,
                       "failure")
Beispiel #3
0
 def process_bind_param(self, value, dialect):
     """Process/Formats the value before insert it into the db."""
     # NOTE(sdague): normalize all the inserts
     if utils.is_valid_ipv6_cidr(value):
         return utils.get_shortened_ipv6_cidr(value)
     return value