Пример #1
0
 def test_get_shortened_ipv6(self):
     self.assertEqual("abcd:ef01:2345:6789:abcd:ef01:c0a8:fefe",
                      utils.get_shortened_ipv6(
                         "abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"))
     self.assertEqual("::1", utils.get_shortened_ipv6(
                                 "0000:0000:0000:0000:0000:0000:0000:0001"))
     self.assertEqual("caca::caca:0:babe:201:102",
                      utils.get_shortened_ipv6(
                                 "caca:0000:0000:caca:0000:babe:0201:0102"))
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "failure")
Пример #2
0
 def test_get_shortened_ipv6(self):
     self.assertEqual(
         "abcd:ef01:2345:6789:abcd:ef01:c0a8:fefe",
         utils.get_shortened_ipv6(
             "abcd:ef01:2345:6789:abcd:ef01:192.168.254.254"))
     self.assertEqual(
         "::1",
         utils.get_shortened_ipv6(
             "0000:0000:0000:0000:0000:0000:0000:0001"))
     self.assertEqual(
         "caca::caca:0:babe:201:102",
         utils.get_shortened_ipv6(
             "caca:0000:0000:caca:0000:babe:0201:0102"))
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "127.0.0.1")
     self.assertRaises(netaddr.AddrFormatError, utils.get_shortened_ipv6,
                       "failure")
Пример #3
0
 def process_bind_param(self, value, dialect):
     """Process/Formats the value before insert it into the db."""
     if dialect.name == 'postgresql':
         return value
     # NOTE(maurosr): The purpose here is to convert ipv6 to the shortened
     # form, not validate it.
     elif netutils.is_valid_ipv6(value):
         return utils.get_shortened_ipv6(value)
     return value