From 7022312148a5644239ec81e16b9b9c692c62c7ff Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 20 Aug 2018 15:27:50 +0100 Subject: Convert IXIA latency statistics to integer JIRA: YARDSTICK-1385 Change-Id: Id50c393da7ded4b3c8e127f7d7a6501832a68446 Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/tests/unit/common/test_utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'yardstick/tests') diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py index ef4142148..3cf6c4d05 100644 --- a/yardstick/tests/unit/common/test_utils.py +++ b/yardstick/tests/unit/common/test_utils.py @@ -1391,3 +1391,19 @@ class GetPortIPTestCase(unittest.TestCase): def test_return_value(self): self.assertEqual('foo', utils.get_port_ip(self.ssh_client, 99)) + + +class SafeCaseTestCase(unittest.TestCase): + + def test_correct_type_int(self): + self.assertEqual(35, utils.safe_cast('35', int, 0)) + + def test_correct_int_as_string(self): + self.assertEqual(25, utils.safe_cast('25', 'int', 0)) + + def test_incorrect_type_as_string(self): + with self.assertRaises(exceptions.InvalidType): + utils.safe_cast('100', 'intt', 0) + + def test_default_value(self): + self.assertEqual(0, utils.safe_cast('', 'int', 0)) -- cgit 1.2.3-korg