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


Python MagicMock.attach方法代码示例

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


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

示例1: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx("PublicIp")
     self.elasticip.resource_id = 'elasticip'
     config = {ALLOCATION_ID: 'elasticip-attach'}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     elasticip.attach(ctx, iface, config)
     self.assertEqual(self.elasticip.resource_id,
                      'elasticip')
     ctx.instance.runtime_properties['allocation_id'] = 'elasticip-attach'
     iface.attach = self.mock_return(config)
     elasticip.attach(ctx, iface, config)
     self.assertEqual(self.elasticip.resource_id,
                      'elasticip')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:16,代码来源:test_elasticip.py

示例2: _stub_volume_client

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def _stub_volume_client(self):
     self.instance_task._volume_client = MagicMock(spec=cinderclient.Client)
     stub_volume_mgr = MagicMock(spec=cinderclient.volumes.VolumeManager)
     self.instance_task.volume_client.volumes = stub_volume_mgr
     stub_volume_mgr.extend = MagicMock(return_value=None)
     stub_new_volume = cinderclient.volumes.Volume(stub_volume_mgr, {"status": "available", "size": 2}, True)
     stub_volume_mgr.get = MagicMock(return_value=stub_new_volume)
     stub_volume_mgr.attach = MagicMock(return_value=None)
开发者ID:rumale,项目名称:trove,代码行数:10,代码来源:test_models.py

示例3: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx("NetworkInterface")
     self.eni.resource_id = 'eni'
     config = {ATTACHMENT_ID: 'eni-attach'}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     eni.attach(ctx, iface, config)
     self.assertEqual(self.eni.resource_id,
                      'eni')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:11,代码来源:test_eni.py

示例4: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx("NetworkAcl")
     self.networkacl.resource_id = 'network acl'
     config = {NETWORKACL_ID: 'network acl', SUBNET_ID: 'subnet'}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     networkacl.attach(ctx, iface, config)
     self.assertEqual(self.networkacl.resource_id,
                      'network acl')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:11,代码来源:test_networkacl.py

示例5: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx("VpnGateway")
     self.vpn_gateway.resource_id = 'vpn gateway'
     config = {VPC_ID: 'vpc', 'Type': type}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     vpn_gateway.attach(ctx, iface, config)
     self.assertEqual(self.vpn_gateway.resource_id,
                      'vpn gateway')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:11,代码来源:test_vpn_gateway.py

示例6: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx("InternetGateway")
     self.internet_gateway.resource_id = 'internet gateway'
     config = {VPC_ID: 'vpc'}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     internet_gateway.attach(ctx, iface, config)
     self.assertEqual(self.internet_gateway.resource_id,
                      'internet gateway')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:11,代码来源:test_internet_gateway.py

示例7: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx("VpnGateway", type_hierarchy=[VPC_TYPE])
     config = {VPNGATEWAY_ID: 'vpn gateway', 'Type': type}
     self.vpn_gateway.resource_id = config[VPNGATEWAY_ID]
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         vpn_gateway.attach(ctx, iface, config)
         self.assertEqual(self.vpn_gateway.resource_id,
                          'vpn gateway')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:12,代码来源:test_vpn_gateway.py

示例8: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx("InternetGateway", type_hierarchy=[VPC_TYPE])
     config = {INTERNETGATEWAY_ID: 'internet gateway'}
     self.internet_gateway.resource_id = config[INTERNETGATEWAY_ID]
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         internet_gateway.attach(ctx, iface, config)
         self.assertEqual(self.internet_gateway.resource_id,
                          'internet gateway')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:12,代码来源:test_internet_gateway.py

示例9: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx("NetworkInterface",
                             type_hierarchy=[INSTANCE_TYPE_DEPRECATED])
     config = {ATTACHMENT_ID: 'eni-attach'}
     self.eni.resource_id = 'eni'
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         eni.attach(ctx, iface, config)
         self.assertEqual(self.eni.resource_id,
                          'eni')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:13,代码来源:test_eni.py

示例10: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx("PublicIp",
                             type_hierarchy=[INSTANCE_TYPE_DEPRECATED])
     config = {ALLOCATION_ID: 'elasticip-attach'}
     self.elasticip.resource_id = 'elasticip'
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         elasticip.attach(ctx, iface, config)
         self.assertEqual(self.elasticip.resource_id,
                          'elasticip')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:13,代码来源:test_elasticip.py

示例11: test_attach

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach(self):
     ctx = self.get_mock_ctx(DHCPOPTIONS)
     self.dhcp.resource_id = 'dhcp'
     config = {VPC_ID: 'vpc',
               'DhcpConfigurations': {'Key': 'domain-name',
                                      'Value': ['example.com']}}
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     dhcp.attach(ctx, iface, config)
     self.assertEqual(self.dhcp.resource_id,
                      'dhcp')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:13,代码来源:test_dhcp.py

示例12: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx(DHCPOPTIONS, type_hierarchy=[VPC_TYPE])
     config = {DHCPOPTIONS_ID: 'dhcp',
               'DhcpConfigurations': {'Key': 'domain-name',
                                      'Value': ['example.com']}}
     self.dhcp.resource_id = config[DHCPOPTIONS_ID]
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         dhcp.attach(ctx, iface, config)
         self.assertEqual(self.dhcp.resource_id,
                          'dhcp')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:14,代码来源:test_dhcp.py

示例13: test_attach_with_relationships

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships(self):
     ctx = self.get_mock_ctx(
         "NetworkAcl",
         type_hierarchy=[SUBNET_TYPE])
     config = {'NewAssociationId': 'foo'}
     self.networkacl.resource_id = 'network acl'
     iface = MagicMock()
     iface.attach = self.mock_return(config)
     iface.resource_id = self.mock_return('network acl')
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         networkacl.attach(ctx, iface, config)
         self.assertEqual(self.networkacl.resource_id,
                          'network acl')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:15,代码来源:test_networkacl.py

示例14: test_attach_with_relationships_eni

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import attach [as 别名]
 def test_attach_with_relationships_eni(self):
     ctx = \
         self.get_mock_ctx("PublicIp",
                           type_hierarchy=[NETWORKINTERFACE_TYPE,
                                           NETWORKINTERFACE_TYPE_DEPRECATED]
                           )
     value = {'AssociationId': 'elasticip-assos'}
     config = {ALLOCATION_ID: 'elasticip-attach', 'Domain': 'vpc'}
     ctx.instance.runtime_properties['allocation_id'] = 'elasticip-attach'
     iface = MagicMock()
     iface.attach = self.mock_return(value)
     with patch('cloudify_aws.common.utils.find_rel_by_node_type'):
         elasticip.attach(ctx, iface, config)
         self.assertEqual(config['Domain'],
                          'vpc')
开发者ID:cloudify-cosmo,项目名称:cloudify-aws-plugin,代码行数:17,代码来源:test_elasticip.py


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