【发布时间】:2021-12-28 20:27:32
【问题描述】:
如何在 test_elastic_network_interfaces_get_by_description 函数中描述 mock_ec2 的网络接口属性?
@mock_ec2 def test_elastic_network_interfaces_get_by_description():
ec2 = boto3.resource("ec2", region_name="us-east-1")
ec2_client= ec2.meta.client
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
vpc.reload()
subnet = ec2.create_subnet(
VpcId=vpc.id, CidrBlock="10.0.0.0/24",
AvailabilityZone="us-east-1a")
desc = str(uuid4())
eni1 = ec2.create_network_interface(
SubnetId=subnet.id, PrivateIpAddress="10.0.10.5", Description=desc )
# The status of the new interface should be 'available'
waiter = ec2_client.get_waiter("network_interface_available")
waiter.wait(NetworkInterfaceIds=[eni1.id])
eni1.modify_attribute(SourceDestCheck={'Value': False})
eni1.reload()
response = eni1.describe_attribute(Attribute='description')
python 3.7
模拟 4.0.3
摩托 2.1.0
当然是 2.0.0
aiobotocore 1.4.2
boto3 1.18.2
botocore 1.20.106
覆盖率 5.5
需要实施或修复什么才能运行或通过测试?
【问题讨论】:
标签: python amazon-ec2 mocking boto3 moto