本文整理汇总了Python中mock.mock.MagicMock.logfile方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.logfile方法的具体用法?Python MagicMock.logfile怎么用?Python MagicMock.logfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.logfile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_configs
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import logfile [as 别名]
def test_update_configs(self, option_parser_mock, curl_mock,
backup_file_mock, file_handler_mock, read_mapping_mock,
get_config_mock, get_config_resp_mock):
file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
opm = option_parser_mock.return_value
options = MagicMock()
args = ["update-configs"]
opm.parse_args.return_value = (options, args)
options.logfile = "logfile"
options.user = "admin"
options.password = "admin"
options.hostname = "localhost"
options.clustername = "c1"
curl_mock.side_effect = ['', '', '', '', '', '', '', '']
read_mapping_mock.return_value = {
"TASKTRACKER": ["c6401", "c6402"],
"JOBTRACKER": ["c6401"],
"MAPREDUCE_CLIENT": ["c6403"]}
get_config_resp_mock.return_value = "hbase-site", {}
site_properties = {
"mapred.hosts": "an_old_value",
"mapred.hosts.exclude": "an_old_value",
"mapred.jobtracker.maxtasks.per.job": "an_old_value",
"hbase.rpc.engine": "an_old_value",
"dfs.df.interval": "an_old_value",
"mapred.userlog.retain.hours": "will_not_be_stored",
"global1": "global11"
}
get_config_mock.side_effect = [
site_properties.copy(), site_properties.copy(), site_properties.copy(),
site_properties.copy(), site_properties.copy(), site_properties.copy()]
saved_global = UpgradeHelper_HDP2.GLOBAL
saved_hdfs = UpgradeHelper_HDP2.HDFS_SITE
saved_core = UpgradeHelper_HDP2.CORE_SITE
saved_habse = UpgradeHelper_HDP2.HBASE_SITE
saved_mapred = UpgradeHelper_HDP2.MAPRED_SITE
try:
UpgradeHelper_HDP2.GLOBAL = {"global2": "REPLACE_WITH_global1"}
UpgradeHelper_HDP2.HDFS_SITE = {"global2": "REPLACE_WITH_global1"}
UpgradeHelper_HDP2.CORE_SITE = {"global2": "REPLACE_WITH_global1"}
UpgradeHelper_HDP2.main()
finally:
UpgradeHelper_HDP2.GLOBAL = saved_global
UpgradeHelper_HDP2.HDFS_SITE = saved_hdfs
UpgradeHelper_HDP2.CORE_SITE = saved_core
UpgradeHelper_HDP2.MAPRED_SITE = saved_mapred
self.assertEqual(7, len(curl_mock.call_args_list))
self.validate_update_config_call(curl_mock.call_args_list[0], "capacity-scheduler")
self.validate_update_config_call(curl_mock.call_args_list[1], "yarn-site")
self.validate_update_config_call(curl_mock.call_args_list[3], "mapred-site")
self.validate_update_config_call(curl_mock.call_args_list[2], "global")
self.validate_config_replacememt(curl_mock.call_args_list[1], "yarn-site")
self.validate_config_replacememt(curl_mock.call_args_list[2], "global")
self.validate_config_replacememt(curl_mock.call_args_list[3], "mapred-site")
self.validate_config_replacememt(curl_mock.call_args_list[4], "hdfs-site")
self.validate_config_replacememt(curl_mock.call_args_list[5], "core-site")
self.validate_config_replacememt(curl_mock.call_args_list[6], "hbase-site")
pass
示例2: test_no_hbase
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import logfile [as 别名]
def test_no_hbase(self, option_parser_mock, curl_mock,
backup_file_mock, file_handler_mock, read_mapping_mock,
get_config_mock, get_config_resp_mock):
file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
opm = option_parser_mock.return_value
options = MagicMock()
args = ["update-configs"]
opm.parse_args.return_value = (options, args)
options.logfile = "logfile"
options.user = "admin"
options.password = "admin"
options.hostname = "localhost"
options.clustername = "c1"
curl_mock.side_effect = ['', '', '', '', '', '', '']
read_mapping_mock.return_value = {
"TASKTRACKER": ["c6401", "c6402"],
"JOBTRACKER": ["c6401"],
"MAPREDUCE_CLIENT": ["c6403"]}
get_config_resp_mock.return_value = "hbase-site", None
get_config_mock.return_value = {
"mapred.hosts": "an_old_value",
"mapred.hosts.exclude": "an_old_value",
"mapred.jobtracker.maxtasks.per.job": "an_old_value",
"mapred.jobtracker.taskScheduler": "an_old_value",
"dfs.df.interval": "an_old_value",
"mapred.userlog.retain.hours": "will_not_be_stored",
"global1": "global11"
}
UpgradeHelper_HDP2.main()
self.assertEqual(6, len(curl_mock.call_args_list))
示例3: get_mock_options
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import logfile [as 别名]
def get_mock_options(self, printonly=False):
options = MagicMock()
options.logfile = "logfile"
options.user = "admin"
options.password = "admin"
options.hostname = "localhost"
options.clustername = "c1"
options.printonly = printonly
return options