Beispiel #1
0
def testIPv6Obj_attributes():
    ## Ensure that attributes are accessible and pass the smell test
    test_object = IPv6Obj("2001::dead:beef/64")
    results_correct = [
        ("ip", IPv6Address("2001::dead:beef")),
        ("ip_object", IPv6Address("2001::dead:beef")),
        ("netmask", IPv6Address("ffff:ffff:ffff:ffff::")),
        ("prefixlen", 64),
        ("network", IPv6Network("2001::/64")),
        ("network_object", IPv6Network("2001::/64")),
        ("hostmask", IPv6Address("::ffff:ffff:ffff:ffff")),
        ("numhosts", 18446744073709551616),
        ("version", 6),
        ("is_reserved", False),
        ("is_multicast", False),
        # ("is_private", False),  # FIXME: disabling this for now...
        # py2.7 and py3.x produce different results
        ("as_cidr_addr", "2001::dead:beef/64"),
        ("as_cidr_net", "2001::/64"),
        ("as_decimal", 42540488161975842760550356429036175087),
        ("as_decimal_network", 42540488161975842760550356425300246528),
        (
            "as_hex_tuple",
            ("2001", "0000", "0000", "0000", "0000", "0000", "dead", "beef"),
        ),
        (
            "as_binary_tuple",
            (
                "0010000000000001",
                "0000000000000000",
                "0000000000000000",
                "0000000000000000",
                "0000000000000000",
                "0000000000000000",
                "1101111010101101",
                "1011111011101111",
            ),
        ),
    ]
    for attribute, result_correct in results_correct:

        assert getattr(test_object, attribute) == result_correct
Beispiel #2
0
def testIPv6Obj_gt_01():
    """Simple greater_than test"""
    assert IPv6Obj("::2") > IPv6Obj("::1")
Beispiel #3
0
def testIPv6Obj_eq_01():
    """Simple equality test"""
    assert IPv6Obj("::1") == IPv6Obj("::1")
Beispiel #4
0
def testIPv6Obj_neq_02():
    """Simple in-equality test"""
    assert IPv6Obj("::1") != IPv6Obj("::2")
Beispiel #5
0
def testIPv6Obj_neq_01():
    """Simple in-equality test fail (ref - Github issue #180)"""
    assert IPv6Obj("::1") != ""
Beispiel #6
0
def testIPv6Obj_recursive():
    """IPv6Obj() should be able to parse itself"""
    obj = IPv6Obj(IPv6Obj("fe80:a:b:c:d:e::1/64"))
    assert str(obj.ip_object) == "fe80:a:b:c:d:e:0:1"
    assert obj.prefixlen == 64