MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / test_create

Function test_create

python/example_code/ec2/test/test_vpc.py:30–47  ·  view source on GitHub ↗
(monkeypatch, make_stubber, error_code)

Source from the content-addressed store, hash-verified

28
29@pytest.mark.parametrize("error_code", [None, "TestException"])
30def test_create(monkeypatch, make_stubber, error_code):
31 ec2_client = boto3.client("ec2")
32 ec2_stubber = make_stubber(ec2_client)
33
34 # Mock the waiters.
35 monkeypatch.setattr(waiter.Waiter, "wait", lambda arg, **kwargs: None)
36
37 wrapper = VpcWrapper(ec2_client)
38 vpc_id = "vpc-a01106c2"
39 cidr_block = "10.0.0.0/16"
40 ec2_stubber.stub_create_vpc(cidr_block, vpc_id, error_code=error_code)
41 if error_code is None:
42 created_vpc_id = wrapper.create(cidr_block)
43 assert created_vpc_id == vpc_id
44 else:
45 with pytest.raises(ClientError) as exc_info:
46 wrapper.create(cidr_block)
47 assert exc_info.value.response["Error"]["Code"] == error_code
48
49
50@pytest.mark.parametrize("error_code", [None, "TestException"])

Callers

nothing calls this directly

Calls 3

createMethod · 0.95
VpcWrapperClass · 0.90
stub_create_vpcMethod · 0.80

Tested by

no test coverage detected