From 1267052bbc7dc3921c429ab299f6335dbe709dc7 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Thu, 26 Jan 2017 11:19:25 -0800 Subject: nsb: move NSB root to constant, add unittest add unittest for non-None default fixup get_nsb_option to return default correctly. use NSB_ROOT for all paths Change-Id: Idd1951a8d436bc49c30d59d84ca12a5f26e9148f Signed-off-by: Ross Brattain --- tests/unit/network_services/test_utils.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/network_services/test_utils.py b/tests/unit/network_services/test_utils.py index ecacac7c3..8d9e74adf 100644 --- a/tests/unit/network_services/test_utils.py +++ b/tests/unit/network_services/test_utils.py @@ -16,6 +16,8 @@ # Unittest for yardstick.network_services.utils from __future__ import absolute_import + +import os import unittest import mock @@ -25,19 +27,24 @@ from yardstick.network_services import utils class UtilsTestCase(unittest.TestCase): """Test all VNF helper methods.""" - DPDK_PATH = "/opt/nsb_bin/dpdk_nic_bind.py" + DPDK_PATH = os.path.join(utils.NSB_ROOT, "dpdk_nic_bind.py") def setUp(self): super(UtilsTestCase, self).setUp() def test_get_nsb_options(self): result = utils.get_nsb_option("bin_path", None) - self.assertEqual(result, "/opt/nsb_bin") + self.assertEqual(result, utils.NSB_ROOT) - def test_get_nsb_optionsi_invalid_key(self): + def test_get_nsb_option_is_invalid_key(self): result = utils.get_nsb_option("bin", None) self.assertEqual(result, None) + def test_get_nsb_option_default(self): + default = object() + result = utils.get_nsb_option("nosuch", default) + self.assertIs(result, default) + def test_provision_tool(self): with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) -- cgit 1.2.3-korg