当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.hostname方法代码示例

本文整理汇总了Python中mock.mock.MagicMock.hostname方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.hostname方法的具体用法?Python MagicMock.hostname怎么用?Python MagicMock.hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.mock.MagicMock的用法示例。


在下文中一共展示了MagicMock.hostname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_configs

# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import hostname [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
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:62,代码来源:TestUpgradeScript_HDP2.py

示例2: test_no_hbase

# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import hostname [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))
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:32,代码来源:TestUpgradeScript_HDP2.py

示例3: get_mock_options

# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import hostname [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
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:11,代码来源:TestUpgradeScript_HDP2.py


注:本文中的mock.mock.MagicMock.hostname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。