aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-08-21 12:54:39 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-08-21 12:54:39 +0000
commit95c0824278c2e273a3017b7c9b8cf6a026950f74 (patch)
tree7885197fbde549981f2adad38a289bbb02b41a86 /yardstick/tests
parenteea4e0e9e2261ef27b5884c51d763b71ff324fb9 (diff)
parent7022312148a5644239ec81e16b9b9c692c62c7ff (diff)
Merge "Convert IXIA latency statistics to integer"
Diffstat (limited to 'yardstick/tests')
-rw-r--r--yardstick/tests/unit/common/test_utils.py16
1 files changed, 16 insertions, 0 deletions
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))