@@ -158,7 +158,8 @@ def __assert_vlan(iface: LinodeInterface):
158158 __assert_vlan (instance .interfaces [2 ])
159159
160160
161- def test_linode_interface_create_public (
161+ @pytest .fixture
162+ def linode_interface_public (
162163 test_linode_client ,
163164 e2e_test_firewall ,
164165 instance_with_interface_generation_linode ,
@@ -169,7 +170,7 @@ def test_linode_interface_create_public(
169170 64 , linode = instance .id
170171 )
171172
172- iface = instance .interface_create (
173+ yield instance .interface_create (
173174 firewall_id = e2e_test_firewall .id ,
174175 default_route = LinodeInterfaceDefaultRouteOptions (
175176 ipv4 = True ,
@@ -192,47 +193,20 @@ def test_linode_interface_create_public(
192193 ]
193194 ),
194195 ),
195- )
196-
197- assert iface .id is not None
198- assert iface .linode_id == instance .id
196+ ), instance , ipv6_range
199197
200- assert iface .created is not None
201- assert iface .updated is not None
202198
203- assert isinstance (iface .mac_address , str )
204- assert iface .version
205-
206- assert iface .default_route .ipv4
207- assert iface .default_route .ipv6
208-
209- assert (
210- iface .public .ipv4 .addresses [0 ].address
211- == instance .ips .ipv4 .public [0 ].address
212- )
213- assert iface .public .ipv4 .addresses [0 ].primary
214- assert len (iface .public .ipv4 .shared ) == 0
215-
216- assert iface .public .ipv6 .ranges [0 ].range == ipv6_range .range
217- assert (
218- iface .public .ipv6 .ranges [0 ].route_target == instance .ipv6 .split ("/" )[0 ]
219- )
220- assert iface .public .ipv6 .slaac [0 ].address == instance .ipv6 .split ("/" )[0 ]
221- assert iface .public .ipv6 .slaac [0 ].prefix == 64
222- assert len (iface .public .ipv6 .shared ) == 0
223-
224-
225- def test_linode_interface_create_vpc (
199+ @pytest .fixture
200+ def linode_interface_vpc (
226201 test_linode_client ,
227202 e2e_test_firewall ,
228- create_vpc_with_subnet ,
229203 instance_with_interface_generation_linode ,
204+ create_vpc_with_subnet ,
230205):
231206 instance : Instance = instance_with_interface_generation_linode
232207 vpc , subnet = create_vpc_with_subnet
233- # subnet_network = ipaddress.ip_network(subnet.ipv4)
234208
235- iface = instance .interface_create (
209+ yield instance .interface_create (
236210 firewall_id = e2e_test_firewall .id ,
237211 default_route = LinodeInterfaceDefaultRouteOptions (
238212 ipv4 = True ,
@@ -255,7 +229,58 @@ def test_linode_interface_create_vpc(
255229 ]
256230 ),
257231 ),
232+ ), instance , vpc , subnet
233+
234+
235+ @pytest .fixture
236+ def linode_interface_vlan (
237+ test_linode_client ,
238+ e2e_test_firewall ,
239+ instance_with_interface_generation_linode ,
240+ create_vpc_with_subnet ,
241+ ):
242+ instance : Instance = instance_with_interface_generation_linode
243+
244+ yield instance .interface_create (
245+ vlan = LinodeInterfaceVLANOptions (
246+ vlan_label = "test-vlan" , ipam_address = "10.0.0.5/32"
247+ ),
248+ ), instance
249+
250+
251+ def test_linode_interface_create_public (linode_interface_public ):
252+ iface , instance , ipv6_range = linode_interface_public
253+
254+ assert iface .id is not None
255+ assert iface .linode_id == instance .id
256+
257+ assert iface .created is not None
258+ assert iface .updated is not None
259+
260+ assert isinstance (iface .mac_address , str )
261+ assert iface .version
262+
263+ assert iface .default_route .ipv4
264+ assert iface .default_route .ipv6
265+
266+ assert (
267+ iface .public .ipv4 .addresses [0 ].address
268+ == instance .ips .ipv4 .public [0 ].address
269+ )
270+ assert iface .public .ipv4 .addresses [0 ].primary
271+ assert len (iface .public .ipv4 .shared ) == 0
272+
273+ assert iface .public .ipv6 .ranges [0 ].range == ipv6_range .range
274+ assert (
275+ iface .public .ipv6 .ranges [0 ].route_target == instance .ipv6 .split ("/" )[0 ]
258276 )
277+ assert iface .public .ipv6 .slaac [0 ].address == instance .ipv6 .split ("/" )[0 ]
278+ assert iface .public .ipv6 .slaac [0 ].prefix == 64
279+ assert len (iface .public .ipv6 .shared ) == 0
280+
281+
282+ def test_linode_interface_create_vpc (linode_interface_vpc ):
283+ iface , instance , vpc , subnet = linode_interface_vpc
259284
260285 assert iface .id is not None
261286 assert iface .linode_id == instance .id
@@ -280,17 +305,9 @@ def test_linode_interface_create_vpc(
280305
281306
282307def test_linode_interface_create_vlan (
283- test_linode_client ,
284- e2e_test_firewall ,
285- instance_with_interface_generation_linode ,
308+ linode_interface_vlan ,
286309):
287- instance : Instance = instance_with_interface_generation_linode
288-
289- iface = instance .interface_create (
290- vlan = LinodeInterfaceVLANOptions (
291- vlan_label = "test-vlan" , ipam_address = "10.0.0.5/32"
292- ),
293- )
310+ iface , instance = linode_interface_vlan
294311
295312 assert iface .id is not None
296313 assert iface .linode_id == instance .id
0 commit comments