mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #4211: Include trailing text when naturalizing interface names
This commit is contained in:
@@ -9,8 +9,8 @@ class NaturalizationTestCase(TestCase):
|
||||
"""
|
||||
def test_naturalize(self):
|
||||
|
||||
# Original, naturalized
|
||||
data = (
|
||||
# Original, naturalized
|
||||
('abc', 'abc'),
|
||||
('123', '00000123'),
|
||||
('abc123', 'abc00000123'),
|
||||
@@ -21,15 +21,16 @@ class NaturalizationTestCase(TestCase):
|
||||
)
|
||||
|
||||
for origin, naturalized in data:
|
||||
self.assertEqual(naturalize(origin, max_length=50), naturalized)
|
||||
self.assertEqual(naturalize(origin, max_length=100), naturalized)
|
||||
|
||||
def test_naturalize_max_length(self):
|
||||
self.assertEqual(naturalize('abc123def456', max_length=10), 'abc0000012')
|
||||
|
||||
def test_naturalize_interface(self):
|
||||
|
||||
# Original, naturalized
|
||||
data = (
|
||||
# Original, naturalized
|
||||
# IOS/JunOS-style
|
||||
('Gi', '9999999999999999Gi000000000000000000'),
|
||||
('Gi1', '9999999999999999Gi000001000000000000'),
|
||||
('Gi1/2', '0001999999999999Gi000002000000000000'),
|
||||
@@ -40,10 +41,16 @@ class NaturalizationTestCase(TestCase):
|
||||
('Gi1/2/3/4/5:6.7', '0001000200030004Gi000005000006000007'),
|
||||
('Gi1:2', '9999999999999999Gi000001000002000000'),
|
||||
('Gi1:2.3', '9999999999999999Gi000001000002000003'),
|
||||
# Generic
|
||||
('Interface 1', '9999999999999999Interface 000001000000000000'),
|
||||
('Interface 1 (other)', '9999999999999999Interface 000001000000000000 (other)'),
|
||||
('Interface 99', '9999999999999999Interface 000099000000000000'),
|
||||
('PCIe1-p1', '9999999999999999PCIe000001000000000000-p00000001'),
|
||||
('PCIe1-p99', '9999999999999999PCIe000001000000000000-p00000099'),
|
||||
)
|
||||
|
||||
for origin, naturalized in data:
|
||||
self.assertEqual(naturalize_interface(origin, max_length=50), naturalized)
|
||||
self.assertEqual(naturalize_interface(origin, max_length=100), naturalized)
|
||||
|
||||
def test_naturalize_interface_max_length(self):
|
||||
self.assertEqual(naturalize_interface('Gi1/2/3', max_length=20), '0001000299999999Gi00')
|
||||
|
Reference in New Issue
Block a user