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


Python AppScaleLogger.should_receive方法代码示例

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


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

示例1: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.function = "appscale-add-keypair"

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()

    # throw some default mocks together for when invoking via shell succeeds
    # and when it fails
    self.fake_temp_file = flexmock(name='fake_temp_file')
    self.fake_temp_file.should_receive('seek').with_args(0).and_return()
    self.fake_temp_file.should_receive('read').and_return('boo out')
    self.fake_temp_file.should_receive('close').and_return()

    flexmock(tempfile)
    tempfile.should_receive('NamedTemporaryFile').and_return(self.fake_temp_file)

    self.success = flexmock(name='success', returncode=0)
    self.success.should_receive('wait').and_return(0)

    self.failed = flexmock(name='success', returncode=1)
    self.failed.should_receive('wait').and_return(1)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:29,代码来源:test_appscale_add_keypair.py

示例2: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    # mock out logging, since it clutters out test output
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()

    # next, pretend our ec2 credentials are properly set
    for credential in EC2Agent.REQUIRED_CREDENTIALS:
      os.environ[credential] = "baz"

    # finally, pretend that our ec2 image to use exists
    fake_ec2 = flexmock(name="fake_ec2")
    fake_ec2.should_receive('get_image').with_args('ami-ABCDEFG') \
      .and_return()
    flexmock(boto)
    boto.should_receive('connect_ec2').with_args('baz', 'baz').and_return(
      fake_ec2)

    # add in some instance variables so that we don't have
    # a lot IP addresses everywhere
    self.blank_input_yaml = None
    self.default_options = {
      'table' : 'cassandra'
    }
    self.ip_1 = '192.168.1.1'
    self.ip_2 = '192.168.1.2'
    self.ip_3 = '192.168.1.3'
    self.ip_4 = '192.168.1.4'
    self.ip_5 = '192.168.1.5'
    self.ip_6 = '192.168.1.6'
    self.ip_7 = '192.168.1.7'
    self.ip_8 = '192.168.1.8'
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:33,代码来源:test_node_layout.py

示例3: test_generate_crash_log

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def test_generate_crash_log(self):
    crashlog_suffix = '123456'
    flexmock(uuid)
    uuid.should_receive('uuid4').and_return(crashlog_suffix)

    exception_class = 'Exception'
    exception_message = 'baz message'
    exception = Exception(exception_message)
    stacktrace = "\n".join(['Traceback (most recent call last):',
      '  File "<stdin>", line 2, in <module>',
      '{0}: {1}'.format(exception_class, exception_message)])

    # Mock out grabbing our system's information
    flexmock(platform)
    platform.should_receive('platform').and_return("MyOS")
    platform.should_receive('python_implementation').and_return("MyPython")

    # Mock out writing it to the crash log file
    expected = '{0}log-{1}'.format(LocalState.LOCAL_APPSCALE_PATH,
      crashlog_suffix)

    fake_file = flexmock(name='fake_file')
    fake_file.should_receive('write').with_args(str)

    fake_builtins = flexmock(sys.modules['__builtin__'])
    fake_builtins.should_call('open')  # set the fall-through
    fake_builtins.should_receive('open').with_args(expected, 'w').and_return(
      fake_file)

    # mock out printing the crash log message
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('warn')

    actual = LocalState.generate_crash_log(exception, stacktrace)
    self.assertEquals(expected, actual)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:37,代码来源:test_local_state.py

示例4: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
    def setUp(self):
        self.keyname = "boobazblargfoo"
        self.function = "appscale-gather-logs"

        # mock out any writing to stdout
        flexmock(AppScaleLogger)
        AppScaleLogger.should_receive("log").and_return()

        # mock out all sleeping
        flexmock(time)
        time.should_receive("sleep").and_return()

        # throw some default mocks together for when invoking via shell succeeds
        # and when it fails
        self.fake_temp_file = flexmock(name="fake_temp_file")
        self.fake_temp_file.should_receive("read").and_return("boo out")
        self.fake_temp_file.should_receive("close").and_return()
        self.fake_temp_file.should_receive("seek").with_args(0).and_return()

        flexmock(tempfile)
        tempfile.should_receive("NamedTemporaryFile").and_return(self.fake_temp_file)

        self.success = flexmock(name="success", returncode=0)
        self.success.should_receive("wait").and_return(0)

        self.failed = flexmock(name="success", returncode=1)
        self.failed.should_receive("wait").and_return(1)
开发者ID:AppScale,项目名称:appscale-tools,代码行数:29,代码来源:test_appscale_gather_logs.py

示例5: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.cloud_argv = ['--min', '1', '--max', '1', '--group', 'blargscale',
      '--infrastructure', 'ec2', '--instance_type', 'm3.medium',
      '--machine', 'ami-ABCDEFG', '--zone', 'my-zone-1b']
    self.cluster_argv = ['--ips', 'ips.yaml']
    self.function = "appscale-run-instances"

    # mock out all logging, since it clutters our output
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()

    # set up phony AWS credentials for each test
    # ones that test not having them present can
    # remove them
    for credential in EucalyptusAgent.REQUIRED_EC2_CREDENTIALS:
      os.environ[credential] = "baz"
    os.environ['EC2_URL'] = "http://boo"

    # pretend that our credentials are valid.
    fake_ec2 = flexmock(name="fake_ec2")
    fake_ec2.should_receive('get_all_instances')

    # similarly, pretend that our image does exist in EC2
    # and Euca
    fake_ec2.should_receive('get_image').with_args('ami-ABCDEFG') \
      .and_return()
    fake_ec2.should_receive('get_image').with_args('emi-ABCDEFG') \
      .and_return('anything')

    # Slip in mocks that assume our EBS volume exists in EC2.
    fake_ec2.should_receive('get_all_volumes').with_args(['vol-ABCDEFG']) \
      .and_return('anything')

    # Also pretend that the availability zone we want to use exists.
    fake_ec2.should_receive('get_all_zones').with_args('my-zone-1b') \
      .and_return('anything')

    # Pretend that a bad availability zone doesn't exist.
    fake_ec2.should_receive('get_all_zones').with_args('bad-zone-1b') \
      .and_raise(boto.exception.EC2ResponseError, 'baz', 'baz')

    # Pretend that we have one elastic IP allocated for use.
    fake_ec2.should_receive('get_all_addresses').with_args('GOOD.IP.ADDRESS') \
      .and_return('anything')

    # Pretend that asking for a bad elastic IP doesn't work.
    fake_ec2.should_receive('get_all_addresses').with_args('BAD.IP.ADDRESS') \
      .and_raise(boto.exception.EC2ResponseError, 'baz', 'baz')

    fake_price = flexmock(name='fake_price', price=1.00)
    fake_ec2.should_receive('get_spot_price_history').and_return([fake_price])

    flexmock(boto)
    flexmock(boto.ec2)
    boto.ec2.should_receive('connect_to_region').with_args('my-zone-1',
      aws_access_key_id='baz', aws_secret_access_key='baz').and_return(fake_ec2)
    boto.ec2.should_receive('connect_to_region').with_args('bad-zone-1',
      aws_access_key_id='baz', aws_secret_access_key='baz').and_return(fake_ec2)
    boto.should_receive('connect_euca').and_return(fake_ec2)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:61,代码来源:test_parse_args.py

示例6: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.function = "appscale-remove-app"

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()
    AppScaleLogger.should_receive('success').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()
开发者ID:AppScale,项目名称:appscale-tools,代码行数:14,代码来源:test_appscale_remove_app.py

示例7: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.function = "appscale-upload-app"
    self.app_dir = "/tmp/baz/gbaz"

    # mock out the check to make sure our app is a directory
    flexmock(os.path)
    os.path.should_call('isdir')
    os.path.should_receive('isdir').with_args(self.app_dir).and_return(True)

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()
    AppScaleLogger.should_receive('success').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()

    local_state = flexmock(LocalState)
    local_state.should_receive('shell').and_return()

    # throw some default mocks together for when invoking via shell succeeds
    # and when it fails
    self.fake_temp_file = flexmock(name='fake_temp_file')
    self.fake_temp_file.should_receive('read').and_return('boo out')
    self.fake_temp_file.should_receive('close').and_return()
    self.fake_temp_file.should_receive('seek').with_args(0).and_return()

    flexmock(tempfile)
    tempfile.should_receive('NamedTemporaryFile').and_return(self.fake_temp_file)

    self.success = flexmock(name='success', returncode=0)
    self.success.should_receive('wait').and_return(0)

    self.failed = flexmock(name='success', returncode=1)
    self.failed.should_receive('wait').and_return(1)

    # mock out generating a random app dir, for later mocks
    flexmock(uuid)
    uuid.should_receive('uuid4').and_return('1234')
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:43,代码来源:test_appscale_upload_app.py

示例8: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.group = "bazboogroup"
    self.function = "appscale-terminate-instances"

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()
    AppScaleLogger.should_receive('verbose').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()

    local_state = flexmock(LocalState)
    local_state.should_receive('shell').and_return("")

    # throw some default mocks together for when invoking via shell succeeds
    # and when it fails
    self.fake_temp_file = flexmock(name='fake_temp_file')
    self.fake_temp_file.should_receive('read').and_return('boo out')
    self.fake_temp_file.should_receive('close').and_return()
    self.fake_temp_file.should_receive('seek').with_args(0).and_return()

    flexmock(tempfile)
    tempfile.should_receive('NamedTemporaryFile').and_return(self.fake_temp_file)

    self.success = flexmock(name='success', returncode=0)
    self.success.should_receive('wait').and_return(0)

    self.failed = flexmock(name='failed', returncode=1)
    self.failed.should_receive('wait').and_return(1)

    # throw in some mocks that assume our EC2 environment variables are set
    for credential in EC2Agent.REQUIRED_EC2_CREDENTIALS:
      os.environ[credential] = "baz"
开发者ID:AppScale,项目名称:appscale-tools,代码行数:38,代码来源:test_appscale_terminate_instances.py

示例9: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
    def setUp(self):
        self.keyname = "boobazblargfoo"
        self.function = "appscale-set-property"

        # mock out any writing to stdout
        flexmock(AppScaleLogger)
        AppScaleLogger.should_receive("log").and_return()
        AppScaleLogger.should_receive("success").and_return()
        AppScaleLogger.should_receive("warn").and_return()

        # mock out all sleeping
        flexmock(time)
        time.should_receive("sleep").and_return()
开发者ID:AppScale,项目名称:appscale-tools,代码行数:15,代码来源:test_appscale_set_property.py

示例10: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.function = "appscale-relocate-app"
    self.appid = 'my-crazy-app'

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()
    AppScaleLogger.should_receive('success').and_return()
    AppScaleLogger.should_receive('warn').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()

    # mock out reading the locations.json file, and slip in our own json
    flexmock(os.path)
    os.path.should_call('exists')  # set the fall-through
    os.path.should_receive('exists').with_args(
      LocalState.get_locations_json_location(self.keyname)).and_return(True)

    fake_nodes_json = flexmock(name="fake_nodes_json")
    fake_nodes_json.should_receive('read').and_return(
      json.dumps({"node_info": [{
        "public_ip": "public1",
        "private_ip": "private1",
        "jobs": ["shadow", "login"]
      }]}))
    fake_nodes_json.should_receive('write').and_return()
    builtins = flexmock(sys.modules['__builtin__'])
    builtins.should_call('open')  # set the fall-through
    builtins.should_receive('open').with_args(
      LocalState.get_locations_json_location(self.keyname), 'r') \
      .and_return(fake_nodes_json)

    # put in a mock for reading the secret file
    secret_key_location = LocalState.get_secret_key_location(self.keyname)
    fake_secret = flexmock(name="fake_secret")
    fake_secret.should_receive('read').and_return('the secret')
    builtins.should_receive('open').with_args(secret_key_location, 'r') \
      .and_return(fake_secret)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:43,代码来源:test_appscale_relocate_app.py

示例11: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    # mock out all logging, since it clutters our output
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()

    # mock out all sleeps, as they aren't necessary for unit testing
    flexmock(time)
    time.should_receive('sleep').and_return()

    # set up some fake options so that we don't have to generate them via
    # ParseArgs
    self.options = flexmock(
      infrastructure='ec2',
      group='boogroup',
      machine='ami-ABCDEFG',
      instance_type='m1.large',
      keyname='bookey',
      table='cassandra',
      verbose=False,
      test=False,
      use_spot_instances=False,
      zone='my-zone-1b',
      static_ip=None,
      replication=None,
      appengine=None,
      autoscale=None,
      user_commands=[],
      flower_password='',
      max_memory='400',
      ips={
        'zookeeper': 'node-2', 'master': 'node-1',
        'appengine': 'node-3', 'database': 'node-4'}
    )
    self.my_id = "12345"
    self.node_layout = NodeLayout(self.options)

    # set up phony AWS credentials for each test
    # ones that test not having them present can
    # remove them
    for credential in EucalyptusAgent.REQUIRED_EC2_CREDENTIALS:
      os.environ[credential] = "baz"
    os.environ['EC2_URL'] = "http://boo"

    # mock out calls to EC2
    # begin by assuming that our ssh keypair doesn't exist, and thus that we
    # need to create it
    key_contents = "key contents here"
    fake_key = flexmock(name="fake_key", material=key_contents)
    fake_key.should_receive('save').with_args(os.environ['HOME']+'/.appscale').and_return(None)

    fake_ec2 = flexmock(name="fake_ec2")
    fake_ec2.should_receive('get_key_pair').with_args('bookey') \
      .and_return(None)
    fake_ec2.should_receive('create_key_pair').with_args('bookey') \
      .and_return(fake_key)

    # mock out writing the secret key
    builtins = flexmock(sys.modules['__builtin__'])
    builtins.should_call('open')  # set the fall-through

    secret_key_location = LocalState.LOCAL_APPSCALE_PATH + "bookey.secret"
    fake_secret = flexmock(name="fake_secret")
    fake_secret.should_receive('write').and_return()
    builtins.should_receive('open').with_args(secret_key_location, 'w') \
      .and_return(fake_secret)

    # also, mock out the keypair writing and chmod'ing
    ssh_key_location = LocalState.LOCAL_APPSCALE_PATH + "bookey.key"
    fake_file = flexmock(name="fake_file")
    fake_file.should_receive('write').with_args(key_contents).and_return()

    builtins.should_receive('open').with_args(ssh_key_location, 'w') \
      .and_return(fake_file)

    flexmock(os)
    os.should_receive('chmod').with_args(ssh_key_location, 0600).and_return()

    # next, assume there are no security groups up at first, but then it gets
    # created.
    udp_rule = flexmock(from_port=1, to_port=65535, ip_protocol='udp')
    tcp_rule = flexmock(from_port=1, to_port=65535, ip_protocol='tcp')
    icmp_rule = flexmock(from_port=-1, to_port=-1, ip_protocol='icmp')
    group = flexmock(name='boogroup', rules=[tcp_rule, udp_rule, icmp_rule])
    fake_ec2.should_receive('get_all_security_groups').with_args().and_return([])
    fake_ec2.should_receive('get_all_security_groups').with_args('boogroup').and_return([group])

    # and then assume we can create and open our security group fine
    fake_ec2.should_receive('create_security_group').with_args('boogroup',
      'AppScale security group').and_return()
    fake_ec2.should_receive('authorize_security_group').and_return()

    # next, add in mocks for run_instances
    # the first time around, let's say that no machines are running
    # the second time around, let's say that our machine is pending
    # and that it's up the third time around
    fake_pending_instance = flexmock(state='pending')
    fake_pending_reservation = flexmock(instances=fake_pending_instance)

    fake_running_instance = flexmock(state='running', key_name='bookey',
      id='i-12345678', ip_address='1.2.3.4', private_ip_address='1.2.3.4')
#.........这里部分代码省略.........
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:103,代码来源:test_remote_helper.py

示例12: setUp

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import should_receive [as 别名]
  def setUp(self):
    self.keyname = "boobazblargfoo"
    self.group = "bazgroup"
    self.function = "appscale-run-instances"

    # mock out any writing to stdout
    flexmock(AppScaleLogger)
    AppScaleLogger.should_receive('log').and_return()
    AppScaleLogger.should_receive('success').and_return()

    # mock out all sleeping
    flexmock(time)
    time.should_receive('sleep').and_return()

    # pretend we have an appscalefile at the right location, and that it
    # specifies the keyname and group
    appscalefile_path = os.getcwd() + os.sep + "AppScalefile"
    flexmock(os.path)
    os.path.should_call('exists')
    os.path.should_receive('exists').with_args(appscalefile_path) \
      .and_return(True)

    appscalefile_contents = """
keyname: {0}
group: {1}
""".format(self.keyname, self.group)

    self.builtins = flexmock(sys.modules['__builtin__'])
    self.builtins.should_call('open')  # set the fall-through
    fake_appscalefile = flexmock(name="fake_appscalefile")
    fake_appscalefile.should_receive('read').and_return(appscalefile_contents)
    fake_appscalefile.should_receive('write').and_return()
    self.builtins.should_receive('open').with_args(appscalefile_path, 'r') \
      .and_return(fake_appscalefile)
    self.builtins.should_receive('open').with_args(appscalefile_path, 'w') \
      .and_return(fake_appscalefile)

    # throw some default mocks together for when invoking via shell succeeds
    # and when it fails
    self.fake_temp_file = flexmock(name='fake_temp_file')
    self.fake_temp_file.should_receive('seek').with_args(0).and_return()
    self.fake_temp_file.should_receive('read').and_return('boo out')
    self.fake_temp_file.should_receive('close').and_return()

    self.fake_input_file = flexmock(name='fake_input_file')
    self.fake_input_file.should_receive('seek').with_args(0).and_return()
    self.fake_input_file.should_receive('write').and_return()
    self.fake_input_file.should_receive('read').and_return('boo out')
    self.fake_input_file.should_receive('close').and_return()

    flexmock(tempfile)
    tempfile.should_receive('NamedTemporaryFile')\
      .and_return(self.fake_temp_file)
    tempfile.should_receive('TemporaryFile').and_return(self.fake_input_file)

    self.success = flexmock(name='success', returncode=0)
    self.success.should_receive('wait').and_return(0)

    self.failed = flexmock(name='failed', returncode=1)
    self.failed.should_receive('wait').and_return(1)

    # throw in some mocks that assume our EC2 environment variables are set
    for credential in EC2Agent.REQUIRED_EC2_CREDENTIALS:
      os.environ[credential] = "baz"

    # mock out interactions with AWS
    self.fake_ec2 = flexmock(name='fake_ec2')

    # And add in mocks for libraries most of the tests mock out
    self.local_state = flexmock(LocalState)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:72,代码来源:test_appscale_run_instances.py


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