本文整理汇总了Python中bootstrap.Bootstrap.copyNeededFiles方法的典型用法代码示例。如果您正苦于以下问题:Python Bootstrap.copyNeededFiles方法的具体用法?Python Bootstrap.copyNeededFiles怎么用?Python Bootstrap.copyNeededFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bootstrap.Bootstrap
的用法示例。
在下文中一共展示了Bootstrap.copyNeededFiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copyNeededFiles
# 需要导入模块: from bootstrap import Bootstrap [as 别名]
# 或者: from bootstrap.Bootstrap import copyNeededFiles [as 别名]
def test_copyNeededFiles(self, write_mock, ssh_run_mock, ssh_init_mock,
scp_run_mock, scp_init_mock,
getRemoteName_mock, getRepoFile_mock, getRepoDir,
getMoveRepoFileCommand, is_redhat_family, is_ubuntu_family, is_suse_family):
shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
None, "8440", "root")
is_redhat_family.return_value = True
is_ubuntu_family.return_value = False
is_suse_family.return_value = False
bootstrap_obj = Bootstrap("hostname", shared_state)
getMoveRepoFileCommand.return_value = "MoveRepoFileCommand"
getRepoDir.return_value = "RepoDir"
getRemoteName_mock.return_value = "RemoteName"
getRepoFile_mock.return_value = "RepoFile"
expected1 = {"exitstatus": 42, "log": "log42", "errormsg": "errorMsg"}
expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
expected3 = {"exitstatus": 1, "log": "log1", "errormsg": "errorMsg"}
expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
scp_init_mock.return_value = None
ssh_init_mock.return_value = None
# Testing max retcode return
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2, expected4]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected1["exitstatus"])
input_file = str(scp_init_mock.call_args[0][3])
remote_file = str(scp_init_mock.call_args[0][4])
self.assertEqual(input_file, "setupAgentFile")
self.assertEqual(remote_file, "RemoteName")
command = str(ssh_init_mock.call_args[0][3])
self.assertEqual(command, "sudo chmod 644 RepoFile")
# Another order
expected1 = {"exitstatus": 0, "log": "log0", "errormsg": "errorMsg"}
expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
expected3 = {"exitstatus": 1, "log": "log1", "errormsg": "errorMsg"}
expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2, expected4]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected2["exitstatus"])
# yet another order
expected1 = {"exitstatus": 33, "log": "log33", "errormsg": "errorMsg"}
expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
expected3 = {"exitstatus": 42, "log": "log42", "errormsg": "errorMsg"}
expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2, expected4]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected3["exitstatus"])
示例2: test_copyNeededFiles
# 需要导入模块: from bootstrap import Bootstrap [as 别名]
# 或者: from bootstrap.Bootstrap import copyNeededFiles [as 别名]
def test_copyNeededFiles(self, write_mock, ssh_run_mock, ssh_init_mock,
scp_run_mock, scp_init_mock,
getRemoteName_mock, getRepoFile_mock, getRepoDir,
getMoveRepoFileCommand):
shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
None, "8440")
bootstrap_obj = Bootstrap("hostname", shared_state)
getMoveRepoFileCommand.return_value = "MoveRepoFileCommand"
getRepoDir.return_value = "RepoDir"
getRemoteName_mock.return_value = "RemoteName"
getRepoFile_mock.return_value = "RepoFile"
expected1 = 42
expected2 = 17
expected3 = 1
scp_init_mock.return_value = None
ssh_init_mock.return_value = None
# Testing max retcode return
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected1)
input_file = str(scp_init_mock.call_args[0][3])
remote_file = str(scp_init_mock.call_args[0][4])
self.assertEqual(input_file, "setupAgentFile")
self.assertEqual(remote_file, "RemoteName")
command = str(ssh_init_mock.call_args[0][3])
self.assertEqual(command, "MoveRepoFileCommand")
# Another order
expected1 = 0
expected2 = 17
expected3 = 1
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected2)
# yet another order
expected1 = 33
expected2 = 17
expected3 = 42
scp_run_mock.side_effect = [expected1, expected3]
ssh_run_mock.side_effect = [expected2]
res = bootstrap_obj.copyNeededFiles()
self.assertEquals(res, expected3)