Skip to content

Commit ef34947

Browse files
Testing progresss
1 parent 8af8c51 commit ef34947

File tree

4 files changed

+86
-9
lines changed

4 files changed

+86
-9
lines changed

linode_api4/linode_client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@ def _api_call(
283283
verify=self.ca_path or self.session.verify,
284284
)
285285

286-
print(
287-
"\nNEW REQUEST:\n", method, url, "\n", body, "\n", response.json()
288-
)
289-
290286
warning = response.headers.get("Warning", None)
291287
if warning:
292288
logger.warning("Received warning from server: {}".format(warning))

linode_api4/objects/linode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ def interfaces_settings(self) -> LinodeInterfacesSettings:
19621962
return self._interfaces_settings
19631963

19641964
@property
1965-
def interfaces(self):
1965+
def interfaces(self) -> List[LinodeInterface]:
19661966
"""
19671967
All interfaces for this Linode.
19681968

linode_api4/objects/linode_interfaces.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass, field
2-
from typing import List, Optional
2+
from typing import List, Optional, Union
33

44
from linode_api4.objects.base import Base, Property
55
from linode_api4.objects.dbase import DerivedBase
@@ -163,7 +163,7 @@ class LinodeInterfaceOptions(JSONObject):
163163
Options accepted when creating or updating a Linode Interface.
164164
"""
165165

166-
firewall_id: Optional[int] = None
166+
firewall_id: Optional[Union[Firewall, int]] = None
167167
default_route: Optional[LinodeInterfaceDefaultRouteOptions] = None
168168
vpc: Optional[LinodeInterfaceVPCOptions] = None
169169
public: Optional[LinodeInterfacePublicOptions] = None
@@ -319,7 +319,7 @@ class LinodeInterfacePublicIPv6(JSONObject):
319319
@dataclass
320320
class LinodeInterfacePublic(JSONObject):
321321
"""
322-
Public-specific configuration field for a Linode Interface.
322+
Public-specific configuration fields for a Linode Interface.
323323
"""
324324

325325
put_class = LinodeInterfacePublicOptions
@@ -331,7 +331,7 @@ class LinodeInterfacePublic(JSONObject):
331331
@dataclass
332332
class LinodeInterfaceVLAN(JSONObject):
333333
"""
334-
VLAN-specific configuration field for a Linode Interface.
334+
VLAN-specific configuration fields for a Linode Interface.
335335
"""
336336

337337
put_class = LinodeInterfaceVLANOptions
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from test.integration.conftest import get_region
2+
from test.integration.helpers import get_test_label
3+
4+
import pytest
5+
6+
from linode_api4 import (
7+
Instance,
8+
InterfaceGeneration,
9+
LinodeInterface,
10+
LinodeInterfaceDefaultRouteOptions,
11+
LinodeInterfaceOptions,
12+
LinodeInterfacePublicOptions,
13+
)
14+
15+
16+
@pytest.fixture(scope="session")
17+
def linode_create_with_interfaces(test_linode_client, e2e_test_firewall):
18+
client = test_linode_client
19+
region = get_region(
20+
client,
21+
{"Linodes", "Cloud Firewall", "Linode Interfaces"},
22+
site_type="core",
23+
)
24+
label = get_test_label()
25+
26+
instance, _ = client.linode.instance_create(
27+
"g6-nanode-1",
28+
region,
29+
image="linode/debian12",
30+
label=label,
31+
interface_generation=InterfaceGeneration.LINODE,
32+
interfaces=[
33+
LinodeInterfaceOptions(
34+
firewall_id=e2e_test_firewall.id,
35+
default_route=LinodeInterfaceDefaultRouteOptions(
36+
ipv4=True,
37+
ipv6=True,
38+
),
39+
public=LinodeInterfacePublicOptions(),
40+
)
41+
],
42+
)
43+
44+
yield instance
45+
46+
instance.delete()
47+
48+
49+
def test_linode_create_with_linode_interfaces(linode_create_with_interfaces):
50+
instance: Instance = linode_create_with_interfaces
51+
52+
def __assert_base(iface: LinodeInterface):
53+
assert iface.id is not None
54+
assert iface.linode_id == instance.id
55+
56+
assert iface.created is not None
57+
assert iface.updated is not None
58+
59+
assert isinstance(iface.mac_address, str)
60+
assert iface.version
61+
62+
def __assert_public(iface: LinodeInterface):
63+
__assert_base(iface)
64+
65+
assert iface.default_route.ipv4
66+
assert iface.default_route.ipv6
67+
68+
assert iface.public.ipv4.addresses[0].address == instance.ipv4[0]
69+
assert iface.public.ipv4.addresses[0].primary
70+
assert len(iface.public.ipv4.shared) == 0
71+
72+
assert iface.public.ipv6.slaac[0].address == instance.ipv6.split("/")[0]
73+
assert iface.public.ipv6.slaac[0].prefix == 64
74+
assert len(iface.public.ipv6.shared) == 0
75+
assert len(iface.public.ipv6.ranges) == 0
76+
77+
__assert_public(instance.interfaces[0])
78+
79+
instance.invalidate()
80+
81+
__assert_public(instance.interfaces[0])

0 commit comments

Comments
 (0)