summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuriy Andamasov <yuriy@vyos.io>2026-04-26 17:43:28 +0300
committerYuriy Andamasov <yuriy@vyos.io>2026-04-26 17:43:28 +0300
commite9c9e404f19088040fb134c333138b379a0eb5a9 (patch)
treef7e735ae2acc4d0bec484d4d668cb5a5a255fc90
parentfd71d68e4a1b379740a66db5ccdad5a30aa08efa (diff)
downloadvyos.vyos-test/vlan-unit-tests.tar.gz
vyos.vyos-test/vlan-unit-tests.zip
T8518: move inline CLI output to fixture filestest/vlan-unit-tests
🤖 Generated by [robots](https://vyos.io)
-rw-r--r--tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces.cfg10
-rw-r--r--tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces_empty.cfg7
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_vlan.py38
3 files changed, 24 insertions, 31 deletions
diff --git a/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces.cfg b/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces.cfg
new file mode 100644
index 00000000..b877a4b6
--- /dev/null
+++ b/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces.cfg
@@ -0,0 +1,10 @@
+Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
+Interface IP Address S/L Description
+--------- ---------- --- -----------
+eth0 10.0.2.15/24 u/u
+eth0.100 - u/u vlan-100
+eth1 - u/u
+eth1.200 192.0.2.1/24 u/u vlan-200
+eth2 - u/u
+lo 127.0.0.1/8 u/u
+ ::1/128
diff --git a/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces_empty.cfg b/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces_empty.cfg
new file mode 100644
index 00000000..06ae56a0
--- /dev/null
+++ b/tests/unit/modules/network/vyos/fixtures/vyos_vlan_show_interfaces_empty.cfg
@@ -0,0 +1,7 @@
+Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
+Interface IP Address S/L Description
+--------- ---------- --- -----------
+eth0 10.0.2.15/24 u/u
+eth1 - u/u
+eth2 - u/u
+lo 127.0.0.1/8 u/u
diff --git a/tests/unit/modules/network/vyos/test_vyos_vlan.py b/tests/unit/modules/network/vyos/test_vyos_vlan.py
index 2b663489..7c8748c0 100644
--- a/tests/unit/modules/network/vyos/test_vyos_vlan.py
+++ b/tests/unit/modules/network/vyos/test_vyos_vlan.py
@@ -26,35 +26,7 @@ from unittest.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_vlan
from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
-from .vyos_module import TestVyosModule
-
-
-# show interfaces output with eth0.100 (vlan 100, description vlan-100)
-# and eth1.200 (vlan 200, ip 192.0.2.1/24, description vlan-200).
-# The parser skips the first 3 lines (Codes line, header, dashes).
-SHOW_INTERFACES_OUTPUT = """\
-Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
-Interface IP Address S/L Description
---------- ---------- --- -----------
-eth0 10.0.2.15/24 u/u
-eth0.100 - u/u vlan-100
-eth1 - u/u
-eth1.200 192.0.2.1/24 u/u vlan-200
-eth2 - u/u
-lo 127.0.0.1/8 u/u
- ::1/128
-"""
-
-# Empty show interfaces — no VLANs configured.
-SHOW_INTERFACES_EMPTY = """\
-Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
-Interface IP Address S/L Description
---------- ---------- --- -----------
-eth0 10.0.2.15/24 u/u
-eth1 - u/u
-eth2 - u/u
-lo 127.0.0.1/8 u/u
-"""
+from .vyos_module import TestVyosModule, load_fixture
class TestVyosVlanModule(TestVyosModule):
@@ -81,9 +53,13 @@ class TestVyosVlanModule(TestVyosModule):
def load_fixtures(self, commands=None, filename=None):
self.load_config.return_value = dict(diff=None, session="session")
if filename == "empty":
- self.run_commands.return_value = [SHOW_INTERFACES_EMPTY]
+ self.run_commands.return_value = [
+ load_fixture("vyos_vlan_show_interfaces_empty.cfg"),
+ ]
else:
- self.run_commands.return_value = [SHOW_INTERFACES_OUTPUT]
+ self.run_commands.return_value = [
+ load_fixture("vyos_vlan_show_interfaces.cfg"),
+ ]
def test_vyos_vlan_present(self):
"""Create a new VLAN with a description on eth2 (not in have)."""