Skip to content

Commit 6c65ee7

Browse files
Add integration tests
1 parent d721a1b commit 6c65ee7

File tree

5 files changed

+92
-23
lines changed

5 files changed

+92
-23
lines changed

linode_api4/objects/linode_interfaces.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,73 +105,74 @@ class LinodeInterfaceVPCIPv4Options(JSONObject):
105105

106106

107107
@dataclass
108-
class LinodeInterfaceVPCOptions(JSONObject):
108+
class LinodeInterfaceVPCIPv6SLAACOptions(JSONObject):
109109
"""
110-
VPC-exclusive options accepted when creating or updating a Linode Interface.
110+
Options accepted for a single SLAAC when creating or updating the IPv6 configuration of a VPC Linode Interface.
111111
112112
NOTE: Linode interfaces may not currently be available to all users.
113113
"""
114114

115-
subnet_id: int = 0
116-
ipv4: Optional[LinodeInterfaceVPCIPv4Options] = None
115+
range: Optional[str] = None
117116

118117

119118
@dataclass
120-
class LinodeInterfacePublicIPv4AddressOptions(JSONObject):
119+
class LinodeInterfaceVPCIPv6RangeOptions(JSONObject):
121120
"""
122-
Options accepted for a single address when creating or updating the IPv4 configuration of a public Linode Interface.
121+
Options accepted for a single range when creating or updating the IPv6 configuration of a VPC Linode Interface.
123122
124123
NOTE: Linode interfaces may not currently be available to all users.
125124
"""
126125

127-
address: str = ""
128-
primary: Optional[bool] = None
126+
range: Optional[str] = None
129127

130128

131129
@dataclass
132-
class LinodeInterfacePublicIPv4Options(JSONObject):
130+
class LinodeInterfaceVPCIPv6Options(JSONObject):
133131
"""
134-
Options accepted when creating or updating the IPv4 configuration of a public Linode Interface.
132+
Options accepted when creating or updating the IPv6 configuration of a VPC Linode Interface.
135133
136134
NOTE: Linode interfaces may not currently be available to all users.
137135
"""
138136

139-
addresses: Optional[List[LinodeInterfacePublicIPv4AddressOptions]] = None
137+
is_public: Optional[bool] = None
138+
slaac: Optional[List[LinodeInterfaceVPCIPv6SLAACOptions]] = None
139+
ranges: Optional[List[LinodeInterfaceVPCIPv6RangeOptions]] = None
140140

141141

142142
@dataclass
143-
class LinodeInterfaceVPCIPv6SLAACOptions(JSONObject):
143+
class LinodeInterfaceVPCOptions(JSONObject):
144144
"""
145-
Options accepted for a single SLAAC when creating or updating the IPv6 configuration of a VPC Linode Interface.
145+
VPC-exclusive options accepted when creating or updating a Linode Interface.
146146
147147
NOTE: Linode interfaces may not currently be available to all users.
148148
"""
149149

150-
range: Optional[str] = None
150+
subnet_id: int = 0
151+
ipv4: Optional[LinodeInterfaceVPCIPv4Options] = None
152+
ipv6: Optional[LinodeInterfaceVPCIPv6Options] = None
151153

152154

153155
@dataclass
154-
class LinodeInterfaceVPCIPv6RangeOptions(JSONObject):
156+
class LinodeInterfacePublicIPv4AddressOptions(JSONObject):
155157
"""
156-
Options accepted for a single range when creating or updating the IPv6 configuration of a VPC Linode Interface.
158+
Options accepted for a single address when creating or updating the IPv4 configuration of a public Linode Interface.
157159
158160
NOTE: Linode interfaces may not currently be available to all users.
159161
"""
160162

161-
range: Optional[str] = None
163+
address: str = ""
164+
primary: Optional[bool] = None
162165

163166

164167
@dataclass
165-
class LinodeInterfaceVPCIPv6Options(JSONObject):
168+
class LinodeInterfacePublicIPv4Options(JSONObject):
166169
"""
167-
Options accepted when creating or updating the IPv6 configuration of a VPC Linode Interface.
170+
Options accepted when creating or updating the IPv4 configuration of a public Linode Interface.
168171
169172
NOTE: Linode interfaces may not currently be available to all users.
170173
"""
171174

172-
is_public: Optional[bool] = None
173-
slaac: Optional[List[LinodeInterfaceVPCIPv6SLAACOptions]] = None
174-
ranges: Optional[List[LinodeInterfaceVPCIPv6RangeOptions]] = None
175+
addresses: Optional[List[LinodeInterfacePublicIPv4AddressOptions]] = None
175176

176177

177178
@dataclass
@@ -352,6 +353,7 @@ class LinodeInterfaceVPC(JSONObject):
352353
subnet_id: int = 0
353354

354355
ipv4: Optional[LinodeInterfaceVPCIPv4] = None
356+
ipv6: Optional[LinodeInterfaceVPCIPv6] = None
355357

356358

357359
@dataclass

test/fixtures/linode_instances_124_interfaces.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@
8080
"range": "192.168.22.32/28"
8181
}
8282
]
83+
},
84+
"ipv6": {
85+
"is_public": true,
86+
"slaac": [
87+
{
88+
"range": "1234::/64",
89+
"address": "1234::5678"
90+
}
91+
],
92+
"ranges": [
93+
{
94+
"range": "4321::/64"
95+
}
96+
]
8397
}
8498
},
8599
"public": null,

test/fixtures/linode_instances_124_interfaces_456.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"vpc": {
1111
"vpc_id": 123456,
1212
"subnet_id": 789,
13-
"ipv4" : {
13+
"ipv4": {
1414
"addresses": [
1515
{
1616
"address": "192.168.22.3",
@@ -21,6 +21,20 @@
2121
{ "range": "192.168.22.16/28"},
2222
{ "range": "192.168.22.32/28"}
2323
]
24+
},
25+
"ipv6": {
26+
"is_public": true,
27+
"slaac": [
28+
{
29+
"range": "1234::/64",
30+
"address": "1234::5678"
31+
}
32+
],
33+
"ranges": [
34+
{
35+
"range": "4321::/64"
36+
}
37+
]
2438
}
2539
},
2640
"public": null,

test/fixtures/linode_instances_124_upgrade-interfaces.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@
8282
"range": "192.168.22.32/28"
8383
}
8484
]
85+
},
86+
"ipv6": {
87+
"is_public": true,
88+
"slaac": [
89+
{
90+
"range": "1234::/64",
91+
"address": "1234::5678"
92+
}
93+
],
94+
"ranges": [
95+
{
96+
"range": "4321::/64"
97+
}
98+
]
8599
}
86100
},
87101
"public": null,

test/unit/objects/linode_interface_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
LinodeInterfaceVPCIPv4AddressOptions,
1515
LinodeInterfaceVPCIPv4Options,
1616
LinodeInterfaceVPCIPv4RangeOptions,
17+
LinodeInterfaceVPCIPv6SLAACOptions,
1718
LinodeInterfaceVPCOptions,
1819
)
1920

@@ -149,6 +150,13 @@ def assert_linode_124_interface_456(iface: LinodeInterface):
149150
assert iface.vpc.ipv4.ranges[0].range == "192.168.22.16/28"
150151
assert iface.vpc.ipv4.ranges[1].range == "192.168.22.32/28"
151152

153+
assert iface.vpc.ipv6.is_public
154+
155+
assert iface.vpc.ipv6.slaac[0].range == "1234::/64"
156+
assert iface.vpc.ipv6.slaac[0].address == "1234::5678"
157+
158+
assert iface.vpc.ipv6.ranges[0].range == "4321::/64"
159+
152160
@staticmethod
153161
def assert_linode_124_interface_789(iface: LinodeInterface):
154162
assert iface.id == 789
@@ -261,6 +269,18 @@ def test_update_vpc(self):
261269
)
262270
]
263271

272+
iface.vpc.ipv6.is_public = False
273+
274+
iface.vpc.ipv6.slaac = [
275+
LinodeInterfaceVPCIPv6SLAACOptions(
276+
range="1233::/64",
277+
)
278+
]
279+
280+
iface.vpc.ipv6.ranges = [
281+
LinodeInterfacePublicIPv6RangeOptions(range="9876::/64")
282+
]
283+
264284
with self.mock_put("/linode/instances/124/interfaces/456") as m:
265285
iface.save()
266286

@@ -282,6 +302,11 @@ def test_update_vpc(self):
282302
],
283303
"ranges": [{"range": "192.168.22.17/28"}],
284304
},
305+
"ipv6": {
306+
"is_public": False,
307+
"slaac": [{"range": "1233::/64"}],
308+
"ranges": [{"range": "9876::/64"}],
309+
},
285310
},
286311
}
287312

0 commit comments

Comments
 (0)