Cidr4 merge algorithm #5
@@ -1,11 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from cidr4_merger import (Cidr4MergerError, cidr4_to_node,
|
||||
find_neighbours_singles, get_group_with_max_mask_len,
|
||||
get_net_addr, get_parent_ip, have_same_parent,
|
||||
lift_lonely_node, make_cidr4, make_groups,
|
||||
make_parent, merge_neighbors, merge_nodes,
|
||||
merge_nodes_recursion, reduce_nodes, sort_nodes)
|
||||
from cidr4_merger import (
|
||||
Cidr4MergerError,
|
||||
cidr4_to_node,
|
||||
find_neighbours_singles,
|
||||
get_group_with_max_mask_len,
|
||||
get_net_addr,
|
||||
get_parent_ip,
|
||||
have_same_parent,
|
||||
lift_lonely_node,
|
||||
make_cidr4,
|
||||
make_groups,
|
||||
make_parent,
|
||||
merge_neighbors,
|
||||
merge_nodes,
|
||||
merge_nodes_recursion,
|
||||
reduce_nodes,
|
||||
sort_nodes,
|
||||
)
|
||||
|
||||
|
||||
def test_true():
|
||||
@@ -218,6 +230,44 @@ def test_make_groups():
|
||||
}
|
||||
|
||||
|
||||
def test_find_neighbours_singles():
|
||||
nodes_with_neighbours = [
|
||||
(0, 2, 12, 0),
|
||||
(1073741824, 2, 3, 0),
|
||||
(2147483648, 2, 1, 2147483648),
|
||||
(3221225472, 2, 2, 2147483648),
|
||||
]
|
||||
groups_with_neighbours = make_groups(nodes_with_neighbours)
|
||||
assert find_neighbours_singles(groups_with_neighbours) == (
|
||||
[
|
||||
((0, 2, 12, 0), (1073741824, 2, 3, 0)),
|
||||
((2147483648, 2, 1, 2147483648), (3221225472, 2, 2, 2147483648)),
|
||||
],
|
||||
[],
|
||||
)
|
||||
|
||||
nodes_with_singles = [
|
||||
(0, 2, 12, 0),
|
||||
(2147483648, 2, 1, 2147483648),
|
||||
]
|
||||
groups_with_singles = make_groups(nodes_with_singles)
|
||||
assert find_neighbours_singles(groups_with_singles) == (
|
||||
[],
|
||||
[(0, 2, 12, 0), (2147483648, 2, 1, 2147483648)],
|
||||
)
|
||||
|
||||
nodes_with_neighbours_n_singles = [
|
||||
(0, 2, 12, 0),
|
||||
(1073741824, 2, 3, 0),
|
||||
(2147483648, 2, 1, 2147483648),
|
||||
]
|
||||
groups_with_singles = make_groups(nodes_with_neighbours_n_singles)
|
||||
assert find_neighbours_singles(groups_with_singles) == (
|
||||
[((0, 2, 12, 0), (1073741824, 2, 3, 0))],
|
||||
[(2147483648, 2, 1, 2147483648)],
|
||||
)
|
||||
|
||||
|
||||
# def test_merge_nodes_recursion():
|
||||
# assert merge_nodes(
|
||||
# [
|
||||
|
||||
Reference in New Issue
Block a user