Skip to content

Commit 2118f7c

Browse files
committed
Use explicit test fixture in unit test
1 parent 421477e commit 2118f7c

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

python/neutron-understack/neutron_understack/tests/test_neutron_understack_mech.py

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
from dataclasses import dataclass
12
from unittest.mock import ANY
23

34
import pytest
4-
from neutron_lib.api.definitions import portbindings
55

66
from neutron_understack import utils
77
from neutron_understack.nautobot import VlanPayload
@@ -13,6 +13,7 @@ def test_with_simple_port(self, understack_driver, port_context):
1313

1414
understack_driver.undersync.sync_devices.assert_called_once()
1515

16+
1617
class TestBindPort:
1718
def test_with_no_trunk(self, mocker, port_context, understack_driver):
1819
mocker.patch("neutron_understack.utils.fetch_connected_interface_uuid")
@@ -126,14 +127,56 @@ def test_vxlan_network(
126127
project_id,
127128
):
128129
mocker.patch.object(understack_driver, "_create_nautobot_namespace")
129-
understack_driver.create_network_postcommit(network_context)
130+
131+
@dataclass
132+
class FakeContext:
133+
current = {
134+
"id": "3b5f0bb1-cd53-4c71-b129-1fe7550dfdf4",
135+
"name": "humpback",
136+
"tenant_id": "f9b40d4a39c4403ab5567da17e71906a",
137+
"admin_state_up": True,
138+
"mtu": 9000,
139+
"status": "ACTIVE",
140+
"subnets": [],
141+
"standard_attr_id": 3926,
142+
"shared": False,
143+
"project_id": "f9b40d4a39c4403ab5567da17e71906a",
144+
"router:external": False,
145+
"provider:network_type": "vxlan",
146+
"provider:physical_network": None,
147+
"provider:segmentation_id": 200025,
148+
"is_default": False,
149+
"availability_zone_hints": [],
150+
"availability_zones": [],
151+
"ipv4_address_scope": None,
152+
"ipv6_address_scope": None,
153+
"vlan_transparent": None,
154+
"description": "",
155+
"l2_adjacency": True,
156+
"tags": [],
157+
"created_at": "2025-03-14T07:06:52Z",
158+
"updated_at": "2025-03-14T07:06:52Z",
159+
"revision_number": 1,
160+
}
161+
network_segments = [
162+
{
163+
"id": "9e56eb8d-f9ec-47d2-ac80-3fde76087c38",
164+
"network_type": "vxlan",
165+
"physical_network": None,
166+
"segmentation_id": 200025,
167+
"network_id": "3b5f0bb1-cd53-4c71-b129-1fe7550dfdf4",
168+
}
169+
]
170+
171+
understack_driver.create_network_postcommit(FakeContext())
172+
130173
understack_driver.nb.ucvni_create.assert_called_once_with(
131-
network_id=str(network_id),
132-
project_id=str(project_id),
174+
network_id="3b5f0bb1-cd53-4c71-b129-1fe7550dfdf4",
175+
project_id="f9b40d4a39c4403ab5567da17e71906a",
133176
ucvni_group=str(ucvni_group_id),
134-
network_name=network_context.current["name"],
177+
network_name="humpback",
135178
)
136179
understack_driver._create_nautobot_namespace.assert_called_once_with(
137-
str(network_id),
180+
"3b5f0bb1-cd53-4c71-b129-1fe7550dfdf4",
138181
network_context.current["router:external"],
139182
)

0 commit comments

Comments
 (0)