From 1e37b7f26adb04b2442821ff6bd9f2c70a572f0c Mon Sep 17 00:00:00 2001 From: chenying Date: Tue, 14 Feb 2017 04:49:04 +0800 Subject: [PATCH] Unit test may failed without client_factory.init() Such as the title Change-Id: Ia1e77d29332ddbfb9462fa093858c1e9cda90b78 (cherry picked from commit ec8e3bbcfba442c6ba65785a183ec450a90766ce) --- karbor/tests/unit/protection/test_nova_protection_plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/karbor/tests/unit/protection/test_nova_protection_plugin.py b/karbor/tests/unit/protection/test_nova_protection_plugin.py index aea56bf6..cb3b110f 100644 --- a/karbor/tests/unit/protection/test_nova_protection_plugin.py +++ b/karbor/tests/unit/protection/test_nova_protection_plugin.py @@ -19,6 +19,7 @@ from karbor.resource import Resource from karbor.services.protection.bank_plugin import Bank from karbor.services.protection.bank_plugin import BankPlugin from karbor.services.protection.bank_plugin import BankSection +from karbor.services.protection import client_factory from karbor.services.protection.protection_plugins.server \ import server_plugin_schemas from karbor.services.protection.protection_plugins.server. \ @@ -277,6 +278,10 @@ def call_hooks(operation, checkpoint, resource, context, parameters, **kwargs): class NovaProtectionPluginTest(base.TestCase): def setUp(self): super(NovaProtectionPluginTest, self).setUp() + with mock.patch.object( + client_factory.karbor_keystone_plugin.KarborKeystonePlugin, + '_do_init'): + client_factory.init() self.cntxt = RequestContext(user_id='demo', project_id='abcd', auth_token='efgh')