aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/common
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-06-20 14:18:57 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-08-08 12:57:42 -0700
commit4545b967760ca795a3c67f043eaca60798a90570 (patch)
tree5ced218450c7fb96e1b6230080fc5cfc901b50fa /tests/unit/common
parent5ce3b6f8c8b3217091e51a6041455738603d90b8 (diff)
IXIA traffic generator
Change-Id: I09bcb3f2c4b945283070d442589d3bf00468abbc Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
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):