本文整理汇总了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')
示例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)
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')