|
1 | 1 | from test.integration.conftest import get_region |
2 | | -from test.integration.helpers import get_test_label |
3 | 2 |
|
4 | 3 | import pytest |
5 | 4 |
|
@@ -154,45 +153,21 @@ def test_get_vpc_default_ranges(test_linode_client): |
154 | 153 | assert len(result.forbidden_ipv4_ranges) > 0 |
155 | 154 |
|
156 | 155 |
|
157 | | -def test_vpc_with_ipv4(test_linode_client): |
158 | | - """ |
159 | | - Tests creating a VPC with ipv4 ranges, getting/listing it, |
160 | | - updating the ipv4, and deleting it. |
161 | | - """ |
| 156 | +def test_vpc_with_ipv4(test_linode_client, create_vpc_with_ipv4): |
162 | 157 | client = test_linode_client |
163 | | - label = get_test_label(length=10) |
164 | | - region = get_region(client, {"VPCs", "Custom VPC IPv4 Ranges"}) |
165 | | - |
166 | | - # Create |
167 | | - vpc = client.vpcs.create( |
168 | | - label=label, |
169 | | - region=region, |
170 | | - description="integration test vpc with ipv4", |
171 | | - ipv4=[{"range": "10.0.0.0/8"}], |
172 | | - ) |
| 158 | + vpc = create_vpc_with_ipv4 |
173 | 159 |
|
174 | | - try: |
175 | | - assert vpc.id is not None |
176 | | - assert vpc.label == label |
177 | | - assert len(vpc.ipv4) > 0 |
178 | | - assert vpc.ipv4[0].range == "10.0.0.0/8" |
| 160 | + assert vpc.id is not None |
| 161 | + assert vpc.ipv4[0].range == "10.0.0.0/8" |
179 | 162 |
|
180 | | - # Get by ID |
181 | | - loaded_vpc = client.load(VPC, vpc.id) |
182 | | - assert loaded_vpc.id == vpc.id |
183 | | - assert loaded_vpc.ipv4[0].range == "10.0.0.0/8" |
| 163 | + loaded_vpc = client.load(VPC, vpc.id) |
| 164 | + assert loaded_vpc.ipv4[0].range == "10.0.0.0/8" |
184 | 165 |
|
185 | | - # List and verify present |
186 | | - all_vpcs = client.vpcs() |
187 | | - vpc_ids = [v.id for v in all_vpcs] |
188 | | - assert vpc.id in vpc_ids |
| 166 | + all_vpcs = client.vpcs() |
| 167 | + assert vpc.id in [v.id for v in all_vpcs] |
189 | 168 |
|
190 | | - # Update ipv4 |
191 | | - vpc.ipv4 = [{"range": "192.168.0.0/17"}] |
192 | | - vpc.save() |
| 169 | + vpc.ipv4 = [{"range": "192.168.0.0/17"}] |
| 170 | + vpc.save() |
193 | 171 |
|
194 | | - updated_vpc = client.load(VPC, vpc.id) |
195 | | - assert updated_vpc.ipv4[0].range == "192.168.0.0/17" |
196 | | - finally: |
197 | | - # Delete |
198 | | - vpc.delete() |
| 172 | + updated_vpc = client.load(VPC, vpc.id) |
| 173 | + assert updated_vpc.ipv4[0].range == "192.168.0.0/17" |
0 commit comments