Skip to content

Commit 40a98e7

Browse files
committed
add unit test
1 parent fccff05 commit 40a98e7

3 files changed

Lines changed: 35 additions & 48 deletions

File tree

test/unit/groups/linode_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from test.unit.base import ClientBaseCase
22
from test.unit.objects.linode_interface_test import (
33
build_interface_options_public,
4+
build_interface_options_rdma_vpc,
45
build_interface_options_vlan,
56
build_interface_options_vpc,
67
)
@@ -128,6 +129,40 @@ def test_instance_create_with_interfaces_linode(self):
128129
"interfaces": [iface._serialize() for iface in interfaces],
129130
}
130131

132+
def test_instance_create_with_interfaces_linode_rdma(self):
133+
"""
134+
Tests that a Linode can be created with RDMA VPC LinodeInterfaces.
135+
"""
136+
137+
interfaces = [
138+
build_interface_options_rdma_vpc(),
139+
]
140+
141+
with self.mock_post("linode/instances/124") as m:
142+
self.client.linode.instance_create(
143+
"g6-nanode-1",
144+
"us-mia",
145+
interface_generation=InterfaceGeneration.LINODE,
146+
interfaces=interfaces,
147+
)
148+
149+
assert m.call_data == {
150+
"region": "us-mia",
151+
"type": "g6-nanode-1",
152+
"interface_generation": "linode",
153+
"interfaces": [iface._serialize() for iface in interfaces],
154+
}
155+
156+
assert m.call_data["interfaces"][0] == {
157+
"firewall_id": -1,
158+
"rdma_vpc": {
159+
"subnet_id": 1234,
160+
"ipv4": {
161+
"addresses": [{"address": "auto", "primary": True}]
162+
},
163+
},
164+
}
165+
131166
def test_create_with_maintenance_policy(self):
132167
"""
133168
Tests that you can create a Linode with a maintenance policy

test/unit/objects/linode_interface_test.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -426,42 +426,3 @@ def test_update_rdma_vpc(self):
426426
},
427427
},
428428
}
429-
430-
def test_rdma_vpc_options_serialization(self):
431-
"""
432-
Tests that the POST-shaped ``LinodeInterfaceOptions`` for an RDMA VPC
433-
interface serializes exactly as described in the API spec.
434-
"""
435-
opts = build_interface_options_rdma_vpc()
436-
437-
assert opts.dict == {
438-
"firewall_id": -1,
439-
"rdma_vpc": {
440-
"subnet_id": 1234,
441-
"ipv4": {
442-
"addresses": [{"address": "auto", "primary": True}],
443-
},
444-
},
445-
}
446-
447-
def test_rdma_vpc_options_serialization_minimal(self):
448-
"""
449-
Tests the minimal RDMA VPC payload (no ``ipv4`` block) per spec
450-
default (the API will assign 1 primary ``auto`` address).
451-
"""
452-
opts = build_interface_options_rdma_vpc_minimal()
453-
454-
assert opts.dict == {
455-
"firewall_id": -1,
456-
"rdma_vpc": {"subnet_id": 1234},
457-
}
458-
459-
def test_rdma_vpc_options_dropped_when_none(self):
460-
"""
461-
Ensures the new ``rdma_vpc`` field doesn't leak into the request
462-
body when unused on a non-RDMA interface.
463-
"""
464-
opts = build_interface_options_public()
465-
466-
assert "rdma_vpc" not in opts.dict
467-

test/unit/objects/vpc_test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,3 @@ def test_create_vpc_without_vpc_type(self):
213213

214214
assert m.call_url == "/vpcs"
215215
assert "vpc_type" not in m.call_data
216-
217-
def test_vpc_type_enum_values(self):
218-
"""
219-
Sanity checks on the ``VPCType`` string enum values.
220-
"""
221-
222-
assert VPCType.regular == "regular"
223-
assert VPCType.rdma == "rdma"
224-
assert str(VPCType.rdma) == "rdma"

0 commit comments

Comments
 (0)