Skip to content

Commit

Permalink
handle IPv6 in test extra_df generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jurraca committed Nov 25, 2024
1 parent bcc25eb commit 3113502
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/merge_base_class_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ def _df_from_network(network, asn=123):
'''
Create a one-row dataframe that holds the extra file rows in the expected format for contains_row().
'''
root_net = int(network.split(".", maxsplit=1)[0])
network_int = int(ipaddress.ip_network(network).network_address)
ipn = ipaddress.ip_network(network)
v = ipn.version
if v == 4:
root_net = int(str(pfx).split(".", maxsplit=1)[0])
else:
root_net = int(str(pfx).split(":", maxsplit=1)[0])
network_int = int(ipn.network_address)
df_extra = pd.DataFrame(
data={"INETS": network_int, "ASNS": asn, "PFXS": network, "PFXS_LEADING": root_net},
index=[0],
Expand Down

0 comments on commit 3113502

Please sign in to comment.