def test_zero(self): """ Test that a value of zero gives us a network of 0.0.0.0. """ ipaddrint = 0 ipaddrstrexp = '0.0.0.0' ipaddrstr = token.ipv4_int_to_str(ipaddrint) self.assertEqual(ipaddrstr, ipaddrstrexp)
def test_negative(self): """ Test a negative int value. """ ipaddrint = -1 self.assertRaises(netaddr.AddrFormatError, lambda: token.ipv4_int_to_str(ipaddrint))
def test_out_of_range(self): """ Test a positive value out of 32-bit range. """ ipaddrint = 4294967296 self.assertRaises(netaddr.AddrFormatError, lambda: token.ipv4_int_to_str(ipaddrint))
def test_uint_max(self): """ Test that a 32-bit UINT MAX value returns 255.255.255.255 """ ipaddrint = 4294967295 ipaddrstrexp = '255.255.255.255' ipaddrstr = token.ipv4_int_to_str(ipaddrint) self.assertEqual(ipaddrstr, ipaddrstrexp)
def test_normal(self): """ Test that a normal IPv4 int value gives us the expected result. """ ipaddrint = 3221225985 ipaddrstrexp = '192.0.2.1' ipaddrstr = token.ipv4_int_to_str(ipaddrint) self.assertEqual(ipaddrstr, ipaddrstrexp)