aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/common
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-08-10 03:56:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-10 03:56:37 +0000
commitdaa256f05a1f42f66a84ad96321bc609aeb1f75b (patch)
tree4d2a0e5fceaa65635b1d0ff18cea0d17416ec3cd /tests/unit/common
parent15d507156c87d030d3f8f98e77a99e72ee5b9a99 (diff)
parent4545b967760ca795a3c67f043eaca60798a90570 (diff)
Merge "IXIA traffic generator"
Diffstat (limited to 'tests/unit/common')
-rw-r--r--tests/unit/common/test_utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 53b56523e..948f8fc98 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -916,6 +916,32 @@ class TestUtils(unittest.TestCase):
result = utils.parse_ini_file('my_path')
self.assertDictEqual(result, expected)
+ def test_join_non_strings(self):
+ self.assertEqual(utils.join_non_strings(':'), '')
+ self.assertEqual(utils.join_non_strings(':', 'a'), 'a')
+ self.assertEqual(utils.join_non_strings(':', 'a', 2, 'c'), 'a:2:c')
+ self.assertEqual(utils.join_non_strings(':', ['a', 2, 'c']), 'a:2:c')
+ self.assertEqual(utils.join_non_strings(':', 'abc'), 'abc')
+
+ def test_validate_non_string_sequence(self):
+ self.assertEqual(utils.validate_non_string_sequence([1, 2, 3]), [1, 2, 3])
+ self.assertIsNone(utils.validate_non_string_sequence('123'))
+ self.assertIsNone(utils.validate_non_string_sequence(1))
+
+ self.assertEqual(utils.validate_non_string_sequence(1, 2), 2)
+ self.assertEqual(utils.validate_non_string_sequence(1, default=2), 2)
+
+ with self.assertRaises(RuntimeError):
+ utils.validate_non_string_sequence(1, raise_exc=RuntimeError)
+
+ def test_error_class(self):
+ with self.assertRaises(RuntimeError):
+ utils.ErrorClass()
+
+ error_instance = utils.ErrorClass(test='')
+ with self.assertRaises(AttributeError):
+ error_instance.get_name()
+
class TestUtilsIpAddrMethods(unittest.TestCase):