Exemplo n.º 1
0
    def test_it_should_return_the_version_of_a_v4_address(self):
        ip = IPv4Address("192.0.43.10")

        self.assertEqual(4, ip.version())
Exemplo n.º 2
0
 def test_it_should_recognise_a_valid_ipv4_address(self):
     self.assertTrue(IPv4Address.is_valid("192.0.43.10"))
Exemplo n.º 3
0
    def test_it_should_implement__eq__for_a_v4str_and_a_v6_addresses(self):
        ip1 = IPv4Address("192.0.43.10")
        ip2 = IPv6Address("2001:500:88:200::20")

        self.assertFalse(str(ip2) == ip1)
Exemplo n.º 4
0
 def test_it_should_return_a_v4_address_as_a_string(self):
     ip = IPv4Address("192.0.43.10")
     
     self.assertEqual("192.0.43.10", str(ip))
Exemplo n.º 5
0
    def test_it_should_calculate_the_network_prefix_of_a_slash_24(self):
        ip = IPv4Address("192.0.43.10")

        self.assertEqual("192.0.43.0", ip.network())
Exemplo n.º 6
0
    def test_it_should_implement__eq__for_a_v4str_and_a_v4_addresses(self):
        ip1 = IPv4Address("192.0.43.10")
        ip2 = IPv4Address("192.0.43.20")

        self.assertTrue(str(ip1) == ip1)
        self.assertFalse(str(ip2) == ip1)
Exemplo n.º 7
0
    def test_it_should_change_the_netmask_to_reflect_the_subnet_prefix_size(self):
        ip = IPv4Address("192.0.43.10")
        ip.prefix_size = 16

        self.assertEqual("255.255.0.0", ip.netmask())
Exemplo n.º 8
0
    def test_it_should_have_a_netmask(self):
        ip = IPv4Address("192.0.43.10")

        self.assertEqual("255.255.255.0", ip.netmask())
Exemplo n.º 9
0
    def test_it_should_have_a_subnet_prefix_size(self):
        ip = IPv4Address("192.0.43.10")

        self.assertEqual(24, ip.prefix_size)
Exemplo n.º 10
0
 def test_it_should_not_recognise_a_non_ip_address_as_v4(self):
     self.assertFalse(IPv4Address.is_valid("not a v4 address"))
Exemplo n.º 11
0
 def test_it_should_not_recognise_an_ipv6_address_as_v4(self):
     self.assertFalse(IPv4Address.is_valid("2001:0500:0088:0200:0000:0000:0000:0010"))