mirror of
https://github.com/Cian-H/I-Form_Server_Node_Deployer.git
synced 2025-12-22 22:22:02 +00:00
cleanup
This commit is contained in:
@@ -4,70 +4,55 @@ from ipaddress import IPv4Address, IPv6Address, ip_address
|
||||
class IPAddress:
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
self.obj: IPv4Address | IPv6Address = ip_address(*args, **kwargs)
|
||||
# to_passthrough = (
|
||||
# "compressed",
|
||||
# "exploded",
|
||||
# "is_global",
|
||||
# "is_link_local",
|
||||
# "is_loopback",
|
||||
# "is_multicast",
|
||||
# "is_private",
|
||||
# "is_reserved",
|
||||
# "is_unspecified",
|
||||
# "max_prefixlen",
|
||||
# "packed",
|
||||
# "reverse_pointer",
|
||||
# "version",
|
||||
# )
|
||||
|
||||
@property
|
||||
def compressed(self) -> str:
|
||||
return self.obj.compressed
|
||||
|
||||
|
||||
@property
|
||||
def exploded(self) -> str:
|
||||
return self.obj.exploded
|
||||
|
||||
|
||||
@property
|
||||
def is_global(self) -> bool:
|
||||
return self.obj.is_global
|
||||
|
||||
|
||||
@property
|
||||
def is_link_local(self) -> bool:
|
||||
return self.obj.is_link_local
|
||||
|
||||
|
||||
@property
|
||||
def is_loopback(self) -> bool:
|
||||
return self.obj.is_loopback
|
||||
|
||||
|
||||
@property
|
||||
def is_multicast(self) -> bool:
|
||||
return self.obj.is_multicast
|
||||
|
||||
|
||||
@property
|
||||
def is_private(self) -> bool:
|
||||
return self.obj.is_private
|
||||
|
||||
|
||||
@property
|
||||
def is_reserved(self) -> bool:
|
||||
return self.obj.is_reserved
|
||||
|
||||
|
||||
@property
|
||||
def is_unspecified(self) -> bool:
|
||||
return self.obj.is_unspecified
|
||||
|
||||
|
||||
@property
|
||||
def max_prefixlen(self) -> int:
|
||||
return self.obj.max_prefixlen
|
||||
|
||||
|
||||
@property
|
||||
def packed(self) -> bytes:
|
||||
return self.obj.packed
|
||||
|
||||
|
||||
@property
|
||||
def reverse_pointer(self) -> str:
|
||||
return self.obj.reverse_pointer
|
||||
|
||||
|
||||
@property
|
||||
def version(self) -> int:
|
||||
return self.obj.version
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import atexit
|
||||
import filecmp
|
||||
from ipaddress import IPv4Address, IPv6Address
|
||||
import os
|
||||
from pathlib import Path
|
||||
import pickle
|
||||
import shutil
|
||||
from ipaddress import IPv4Address, IPv6Address
|
||||
|
||||
from hypothesis import given
|
||||
from hypothesis import strategies as st
|
||||
@@ -36,7 +36,7 @@ def cleanup():
|
||||
|
||||
atexit.register(cleanup)
|
||||
|
||||
from node_deployer import ip_interface, autoignition, create_disk, create_img # noqa: E402
|
||||
from node_deployer import autoignition, create_disk, create_img, ip_interface # noqa: E402
|
||||
|
||||
|
||||
with open(config.PROJECT_ROOT / "tests/data/node_deployer/test_args.toml", "rb") as f:
|
||||
@@ -61,36 +61,36 @@ class TestIPInterface:
|
||||
"reverse_pointer",
|
||||
"version",
|
||||
)
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=4))
|
||||
def test_ipv4_parsing(self, ip: IPv4Address):
|
||||
ip_str = str(ip)
|
||||
test_result = ip_interface.IPAddress(ip_str)
|
||||
assert test_result.obj == ip
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=4))
|
||||
def test_ipv4_attr_passthrough(self, ip: IPv4Address):
|
||||
ip_addr = ip_interface.IPAddress(str(ip))
|
||||
for attr in self.TEST_ATTRS:
|
||||
assert getattr(ip_addr, attr) == getattr(ip_addr.obj, attr)
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=4))
|
||||
def test_ipv4_bool(self, ip: IPv4Address):
|
||||
ip_addr = ip_interface.IPAddress(str(ip))
|
||||
assert bool(ip_addr) != ip.is_unspecified
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=6))
|
||||
def test_ipv6_parsing(self, ip: IPv6Address):
|
||||
ip_str = str(ip)
|
||||
test_result = ip_interface.IPAddress(ip_str)
|
||||
assert test_result.obj == ip
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=6))
|
||||
def test_ipv6_attr_passthrough(self, ip: IPv6Address):
|
||||
ip_addr = ip_interface.IPAddress(str(ip))
|
||||
for attr in self.TEST_ATTRS:
|
||||
assert getattr(ip_addr, attr) == getattr(ip_addr.obj, attr)
|
||||
|
||||
|
||||
@given(st.ip_addresses(v=6))
|
||||
def test_ipv6_bool(self, ip: IPv6Address):
|
||||
ip_addr = ip_interface.IPAddress(str(ip))
|
||||
|
||||
Reference in New Issue
Block a user