Fix unit test failure

This patch fixes the unit test for os_profiler. The assertion is made
based on whether os_profiler is installed (importable).

Change-Id: I52e47b07c019e73fc57b5c6461a4b33d87e4392a
Closes-Bug: 1706885
This commit is contained in:
tengqm 2017-08-08 22:01:28 -04:00
parent 65dcd7e75d
commit 821b27f19b
2 changed files with 5 additions and 3 deletions

View File

@ -99,7 +99,7 @@ class SenlinShell(object):
print(' '.join(commands | options))
def add_profiler_args(self, parser):
if isinstance(osprofiler_profiler, int):
if osprofiler_profiler:
parser.add_argument(
'--os-profile',
metavar='HMAC_KEY',

View File

@ -191,8 +191,10 @@ class ShellTest(testtools.TestCase):
parser = mock.Mock()
sh.add_profiler_args(parser)
self.assertEqual(0, parser.add_argument.call_count)
if shell.osprofiler_profiler:
self.assertEqual(1, parser.add_argument.call_count)
else:
self.assertEqual(0, parser.add_argument.call_count)
@mock.patch.object(utils, 'import_versioned_module')
@mock.patch.object(shell.SenlinShell, '_find_actions')