Fix direct patches of methods in test_versionhandler.py
Direct patches of methods in unit test may cause errors in other tests. I use the form of decorators to fix them. Change-Id: I22d92921ae6074be3f4fbd542af8aa9f4c5c5543
This commit is contained in:
parent
ddc87b149f
commit
227d12e602
@ -16,8 +16,6 @@
|
|||||||
import mock
|
import mock
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from sahara.plugins.vanilla.hadoop2 import run_scripts as run
|
|
||||||
from sahara.plugins.vanilla.hadoop2 import starting_scripts as s_scripts
|
|
||||||
from sahara.plugins.vanilla.v2_7_1.edp_engine import EdpOozieEngine
|
from sahara.plugins.vanilla.v2_7_1.edp_engine import EdpOozieEngine
|
||||||
from sahara.plugins.vanilla.v2_7_1.edp_engine import EdpSparkEngine
|
from sahara.plugins.vanilla.v2_7_1.edp_engine import EdpSparkEngine
|
||||||
from sahara.plugins.vanilla.v2_7_1 import versionhandler as v_h
|
from sahara.plugins.vanilla.v2_7_1 import versionhandler as v_h
|
||||||
@ -72,25 +70,19 @@ class VersionHandlerTest(base.SaharaTestCase):
|
|||||||
self.vh.configure_cluster(self.cluster)
|
self.vh.configure_cluster(self.cluster)
|
||||||
configure_cluster.assert_called_once_with(self.vh.pctx, self.cluster)
|
configure_cluster.assert_called_once_with(self.vh.pctx, self.cluster)
|
||||||
|
|
||||||
|
@mock.patch(plugin_path + 'v2_7_1.versionhandler.run')
|
||||||
|
@mock.patch(plugin_path + 'v2_7_1.versionhandler.s_scripts')
|
||||||
@mock.patch('sahara.swift.swift_helper.install_ssl_certs')
|
@mock.patch('sahara.swift.swift_helper.install_ssl_certs')
|
||||||
@mock.patch(plugin_hadoop2_path + 'keypairs.provision_keypairs')
|
@mock.patch(plugin_hadoop2_path + 'keypairs.provision_keypairs')
|
||||||
@mock.patch('sahara.plugins.utils.get_instances')
|
@mock.patch('sahara.plugins.utils.get_instances')
|
||||||
@mock.patch('sahara.utils.cluster.get_instances')
|
@mock.patch('sahara.utils.cluster.get_instances')
|
||||||
def test_start_cluster(self, c_get_instances, u_get_instances,
|
def test_start_cluster(self, c_get_instances, u_get_instances,
|
||||||
provision_keypairs, install_ssl_certs):
|
provision_keypairs, install_ssl_certs,
|
||||||
|
s_scripts, run):
|
||||||
self.vh.pctx = mock.Mock()
|
self.vh.pctx = mock.Mock()
|
||||||
instances = mock.Mock()
|
instances = mock.Mock()
|
||||||
s_scripts.start_namenode = mock.Mock()
|
|
||||||
s_scripts.start_secondarynamenode = mock.Mock()
|
|
||||||
s_scripts.start_resourcemanager = mock.Mock()
|
|
||||||
s_scripts.start_historyserver = mock.Mock()
|
|
||||||
s_scripts.start_oozie = mock.Mock()
|
|
||||||
s_scripts.start_hiveserver = mock.Mock()
|
|
||||||
s_scripts.start_spark = mock.Mock()
|
|
||||||
c_get_instances.return_value = instances
|
c_get_instances.return_value = instances
|
||||||
u_get_instances.return_value = instances
|
u_get_instances.return_value = instances
|
||||||
run.await_datanodes = mock.Mock()
|
|
||||||
run.start_dn_nm_processes = mock.Mock()
|
|
||||||
self.vh._set_cluster_info = mock.Mock()
|
self.vh._set_cluster_info = mock.Mock()
|
||||||
self.vh.start_cluster(self.cluster)
|
self.vh.start_cluster(self.cluster)
|
||||||
provision_keypairs.assert_called_once_with(self.cluster)
|
provision_keypairs.assert_called_once_with(self.cluster)
|
||||||
|
Loading…
Reference in New Issue
Block a user