summaryrefslogtreecommitdiffstats
path: root/test/test-iputil.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-iputil.py')
-rwxr-xr-xtest/test-iputil.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/test-iputil.py b/test/test-iputil.py
index 8f364ad..3af734f 100755
--- a/test/test-iputil.py
+++ b/test/test-iputil.py
@@ -1,11 +1,12 @@
#!/usr/bin/python3
import json
import shutil
+import socket
import logging
import unittest
import ipaddress
import subprocess
-from staslib import iputil, log, trid
+from staslib import iputil, log, stas, trid
IP = shutil.which('ip')
@@ -39,6 +40,12 @@ class Test(unittest.TestCase):
self.assertEqual('', iputil.get_interface('255.255.255.255'))
+ def test_mac2iface(self):
+ for iface in self.ifaces:
+ address = iface.get('address', None)
+ if address:
+ self.assertEqual(iface['ifname'], iputil.mac2iface(address))
+
def test_remove_invalid_addresses(self):
good_tcp = trid.TID({'transport': 'tcp', 'traddr': '1.1.1.1', 'subsysnqn': '', 'trsvcid': '8009'})
bad_tcp = trid.TID({'transport': 'tcp', 'traddr': '555.555.555.555', 'subsysnqn': '', 'trsvcid': '8009'})
@@ -51,7 +58,7 @@ class Test(unittest.TestCase):
any_fc,
bad_trtype,
]
- l2 = iputil.remove_invalid_addresses(l1)
+ l2 = stas.remove_invalid_addresses(l1)
self.assertNotEqual(l1, l2)
@@ -61,6 +68,11 @@ class Test(unittest.TestCase):
self.assertNotIn(bad_tcp, l2)
self.assertNotIn(bad_trtype, l2)
+ def test__data_matches_ip(self):
+ self.assertFalse(iputil._data_matches_ip(None, None, None))
+ self.assertFalse(iputil._data_matches_ip(socket.AF_INET, None, None))
+ self.assertFalse(iputil._data_matches_ip(socket.AF_INET6, None, None))
+
if __name__ == "__main__":
unittest.main()