From 4545b967760ca795a3c67f043eaca60798a90570 Mon Sep 17 00:00:00 2001 From: Deepak S Date: Tue, 20 Jun 2017 14:18:57 -0700 Subject: IXIA traffic generator Change-Id: I09bcb3f2c4b945283070d442589d3bf00468abbc Signed-off-by: Deepak S Signed-off-by: Edward MacGillivray Signed-off-by: Ross Brattain --- tests/unit/common/test_utils.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/unit/common') 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): -- cgit 1.2.3-korg