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


Python AppScale.register方法代码示例

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


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

示例1: test_register

# 需要导入模块: from appscale import AppScale [as 别名]
# 或者: from appscale.AppScale import register [as 别名]
  def test_register(self):
    appscale_yaml = {'keyname': 'boo'}
    deployment = {
      'name': 'bar',
      'deployment_id': 'baz',
      'nodes': [{'public_ip': 'public1', 'jobs': ['shadow']}]
    }

    flexmock(AppScale).should_receive('read_appscalefile')\
      .and_return(yaml.dump(appscale_yaml))
    flexmock(yaml).should_receive('safe_load').and_return({'keyname': 'boo'})

    flexmock(AppScale).should_receive('get_nodes')\
      .and_return(deployment['nodes'])
    flexmock(AppScale).should_receive('get_head_node')\
      .and_return(deployment['nodes'][0])

    flexmock(RegistrationHelper).should_receive('update_deployment') \
      .and_return(deployment)
    flexmock(RegistrationHelper).should_receive('set_deployment_id') \
      .and_return()

    appscale = AppScale()

    # If the deployment already has an ID and it differs from the one given,
    # the tools should raise an AppScaleException.
    existing_deployment_id = 'blarg'
    flexmock(RegistrationHelper).should_receive('appscale_has_deployment_id')\
      .and_return(True)
    flexmock(RegistrationHelper).should_receive('get_deployment_id')\
      .and_return(existing_deployment_id)
    with self.assertRaises(AppScaleException):
      appscale.register(deployment['deployment_id'])

    # If the existing deployment ID is the same as the given deployment ID,
    # the tools should try to complete the registration with the portal.
    existing_deployment_id = 'baz'
    flexmock(RegistrationHelper).should_receive('get_deployment_id') \
      .and_return(existing_deployment_id)
    appscale.register(deployment['deployment_id'])

    # If the deployment does not have an ID set, the tools should try to
    # complete the registration.
    flexmock(RegistrationHelper).should_receive('appscale_has_deployment_id')\
      .and_return(False)
    appscale.register(deployment['deployment_id'])
开发者ID:cdonati,项目名称:appscale-tools,代码行数:48,代码来源:test_appscale_register.py


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