diff --git a/docs/user/include_jinja_list.md b/docs/user/include_jinja_list.md index b59066ec..219e04db 100644 --- a/docs/user/include_jinja_list.md +++ b/docs/user/include_jinja_list.md @@ -40,7 +40,7 @@ | ipaddress_address | netutils.ip.ipaddress_address | | ipaddress_interface | netutils.ip.ipaddress_interface | | ipaddress_network | netutils.ip.ipaddress_network | -| is_classfull | netutils.ip.is_classfull | +| is_classful | netutils.ip.is_classful | | is_ip | netutils.ip.is_ip | | is_netmask | netutils.ip.is_netmask | | netmask_to_cidr | netutils.ip.netmask_to_cidr | diff --git a/netutils/ip.py b/netutils/ip.py index 3183e104..afbe91a2 100644 --- a/netutils/ip.py +++ b/netutils/ip.py @@ -158,8 +158,8 @@ def ip_subtract(ip: str, val: int) -> str: return str(ipaddress.ip_address(ip) - val) -def is_classfull(ip_network: str) -> bool: # noqa: D300,D301 - """Determines if a CIDR network address is within unicast class full boundaries. +def is_classful(ip_network: str) -> bool: # noqa: D300,D301 + """Determines if a CIDR network address is within unicast classful boundaries. The following class boundaries are checked: @@ -171,11 +171,11 @@ def is_classfull(ip_network: str) -> bool: # noqa: D300,D301 ip_network: A network string that can be parsed by ipaddress.ip_network. Returns: - Whether or not the network falls within class full boundaries. + Whether or not the network falls within classful boundaries. Examples: - >>> from netutils.ip import is_classfull - >>> is_classfull("192.168.0.0/24") + >>> from netutils.ip import is_classful + >>> is_classful("192.168.0.0/24") True >>> from jinja2 import Environment @@ -186,7 +186,7 @@ def is_classfull(ip_network: str) -> bool: # noqa: D300,D301 >>> >>> template_str = \"\"\" ... {%- for net in networks %} - ... {% if net | is_classfull %} + ... {% if net | is_classful %} ... network {{ net | ipaddress_network('network_address') }} ... {% else %} ... network {{ net | ipaddress_network('network_address') }} mask {{ net | ipaddress_network('netmask') }} @@ -200,7 +200,7 @@ def is_classfull(ip_network: str) -> bool: # noqa: D300,D301 network 172.16.1.0 mask 255.255.255.0 """ net = ipaddress.ip_network(ip_network) - # Only IPv4 addresses can be classified as class full + # Only IPv4 addresses can be classified as classful if net.version != 4: return False first_octet = net.network_address.packed[0] diff --git a/netutils/utils.py b/netutils/utils.py index e9b35bdb..ff52ac7a 100644 --- a/netutils/utils.py +++ b/netutils/utils.py @@ -32,7 +32,7 @@ "ip_addition": "ip.ip_addition", "ip_to_bin": "ip.ip_to_bin", "ip_subtract": "ip.ip_subtract", - "is_classfull": "ip.is_classfull", + "is_classful": "ip.is_classful", "is_ip": "ip.is_ip", "is_netmask": "ip.is_netmask", "netmask_to_cidr": "ip.netmask_to_cidr", diff --git a/tests/unit/test_ip.py b/tests/unit/test_ip.py index efc89017..442fe22d 100644 --- a/tests/unit/test_ip.py +++ b/tests/unit/test_ip.py @@ -319,7 +319,7 @@ {"sent": 0xFFFFFFFFFFFFFFFF, "received": 64}, ] -IS_CLASSFULL = [ +IS_CLASSFUL = [ {"sent": {"ip_network": "0.0.0.0/8"}, "received": True}, {"sent": {"ip_network": "127.0.0.0/8"}, "received": True}, {"sent": {"ip_network": "128.0.0.0/8"}, "received": False}, @@ -447,6 +447,6 @@ def test_ipaddress_network(data): assert ip.ipaddress_network(**data["sent"]) == data["received"] -@pytest.mark.parametrize("data", IS_CLASSFULL) +@pytest.mark.parametrize("data", IS_CLASSFUL) def test_is_classful(data): - assert ip.is_classfull(**data["sent"]) == data["received"] + assert ip.is_classful(**data["sent"]) == data["received"]