ipaddons 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ipaddons-0.2.2 → ipaddons-0.2.3}/PKG-INFO +1 -1
- {ipaddons-0.2.2 → ipaddons-0.2.3}/pyproject.toml +2 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/src/ipaddons/_version.py +2 -2
- {ipaddons-0.2.2 → ipaddons-0.2.3}/src/ipaddons/tools.py +3 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/tests/test_ip_allocation.py +18 -1
- {ipaddons-0.2.2 → ipaddons-0.2.3}/.gitignore +0 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/LICENSE +0 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/README.md +0 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/src/ipaddons/__init__.py +0 -0
- {ipaddons-0.2.2 → ipaddons-0.2.3}/src/ipaddons/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipaddons
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Additional tools for the ipaddress standard library module
|
|
5
5
|
Project-URL: docs, https://ipaddress-tools.readthedocs.io/stable/
|
|
6
6
|
Project-URL: homepage, https://ipaddress-tools.readthedocs.io/stable/
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.2.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 2,
|
|
31
|
+
__version__ = version = '0.2.3'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 3)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -81,6 +81,9 @@ def merge_ranges(ranges: list[NetworkRange]) -> list[NetworkRange]:
|
|
|
81
81
|
:param ranges: A list of network ranges.
|
|
82
82
|
:return: A list of network ranges with overlapping ranges merged into one.
|
|
83
83
|
"""
|
|
84
|
+
if not len(ranges):
|
|
85
|
+
# Empty range
|
|
86
|
+
return []
|
|
84
87
|
sorted_ranges = sorted(ranges, reverse=True)
|
|
85
88
|
merged_ranges = []
|
|
86
89
|
base = sorted_ranges.pop()
|
|
@@ -57,6 +57,10 @@ mergeable_subnets = [
|
|
|
57
57
|
(v4_supernet_string, v4_subnet_strings, IPv4Allocation, ipaddress.IPv4Network),
|
|
58
58
|
(v6_supernet, v6_subnets, IPv6Allocation, ipaddress.IPv6Network),
|
|
59
59
|
(v6_supernet_string, v6_subnet_strings, IPv6Allocation, ipaddress.IPv6Network),
|
|
60
|
+
(v4_supernet, v4_subnets[:1], IPv4Allocation, ipaddress.IPv4Network),
|
|
61
|
+
(v6_supernet, v6_subnets[:1], IPv6Allocation, ipaddress.IPv6Network),
|
|
62
|
+
(v4_supernet, [], IPv4Allocation, ipaddress.IPv4Network),
|
|
63
|
+
(v6_supernet, [], IPv6Allocation, ipaddress.IPv6Network),
|
|
60
64
|
],
|
|
61
65
|
)
|
|
62
66
|
def test_allocation_classes(supernet, subnets, allocation_class, network_class):
|
|
@@ -86,7 +90,20 @@ def test_allocation_ranges(supernet, subnets, subnet_ranges):
|
|
|
86
90
|
assert sorted(a._used_network_ranges) == sorted(subnet_ranges)
|
|
87
91
|
|
|
88
92
|
|
|
89
|
-
@pytest.mark.parametrize(
|
|
93
|
+
@pytest.mark.parametrize(
|
|
94
|
+
"subnets",
|
|
95
|
+
mergeable_subnets,
|
|
96
|
+
)
|
|
90
97
|
def test_merge(subnets):
|
|
91
98
|
covering_prefix = subnets[0]
|
|
92
99
|
assert tools.merge_ranges(subnets) == [covering_prefix]
|
|
100
|
+
|
|
101
|
+
@pytest.mark.parametrize(
|
|
102
|
+
"subnets",
|
|
103
|
+
mergeable_subnets,
|
|
104
|
+
)
|
|
105
|
+
def test_merge_one(subnets):
|
|
106
|
+
assert tools.merge_ranges(subnets[:1]) == subnets[:1]
|
|
107
|
+
|
|
108
|
+
def test_merge_empty():
|
|
109
|
+
assert tools.merge_ranges([]) == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|