mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Fix tests
This commit is contained in:
parent
55d02b3c2c
commit
e94d00c2c1
@ -211,16 +211,25 @@ class TestPrefix(TestCase):
|
||||
IPAddress(address=IPNetwork('10.0.0.5/26')),
|
||||
IPAddress(address=IPNetwork('10.0.0.7/26')),
|
||||
))
|
||||
# Range is not marked as populated, so it doesn't count against available IP space
|
||||
IPRange.objects.create(
|
||||
start_address=IPNetwork('10.0.0.9/26'),
|
||||
end_address=IPNetwork('10.0.0.12/26')
|
||||
end_address=IPNetwork('10.0.0.10/26')
|
||||
)
|
||||
# Populated range reduces available IP space
|
||||
IPRange.objects.create(
|
||||
start_address=IPNetwork('10.0.0.12/26'),
|
||||
end_address=IPNetwork('10.0.0.13/26'),
|
||||
mark_populated=True
|
||||
)
|
||||
missing_ips = IPSet([
|
||||
'10.0.0.2/32',
|
||||
'10.0.0.4/32',
|
||||
'10.0.0.6/32',
|
||||
'10.0.0.8/32',
|
||||
'10.0.0.13/32',
|
||||
'10.0.0.9/32',
|
||||
'10.0.0.10/32',
|
||||
'10.0.0.11/32',
|
||||
'10.0.0.14/32',
|
||||
])
|
||||
available_ips = parent_prefix.get_available_ips()
|
||||
@ -286,8 +295,12 @@ class TestPrefix(TestCase):
|
||||
])
|
||||
self.assertEqual(prefix.get_utilization(), 32 / 254 * 100) # ~12.5% utilization
|
||||
|
||||
# Create a child range with 32 additional IPs
|
||||
IPRange.objects.create(start_address=IPNetwork('10.0.0.33/24'), end_address=IPNetwork('10.0.0.64/24'))
|
||||
# Create a utilized child range with 32 additional IPs
|
||||
IPRange.objects.create(
|
||||
start_address=IPNetwork('10.0.0.33/24'),
|
||||
end_address=IPNetwork('10.0.0.64/24'),
|
||||
mark_utilized=True
|
||||
)
|
||||
self.assertEqual(prefix.get_utilization(), 64 / 254 * 100) # ~25% utilization
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user