summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-06-01 21:33:44 +1000
committeromnom62 <omnom62@outlook.com>2026-06-01 21:33:44 +1000
commit710e61bc17a8354c824dba4ea53a71013fe1b0e1 (patch)
tree149d097f715f1f9b76930c9d1159eb1aefc85ffd
parentefcfa5c9922206385888d613385a341d4f3d4d06 (diff)
downloadrest.vyos-710e61bc17a8354c824dba4ea53a71013fe1b0e1.tar.gz
rest.vyos-710e61bc17a8354c824dba4ea53a71013fe1b0e1.zip
Test framework updates
-rw-r--r--tests/unit/__init__.py0
-rw-r--r--tests/unit/modules/__init__.py0
-rw-r--r--tests/unit/modules/test_vyos_ntp_global.py22
-rw-r--r--tests/unit/modules/test_vyos_route_maps.py21
4 files changed, 34 insertions, 9 deletions
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/unit/__init__.py
diff --git a/tests/unit/modules/__init__.py b/tests/unit/modules/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/unit/modules/__init__.py
diff --git a/tests/unit/modules/test_vyos_ntp_global.py b/tests/unit/modules/test_vyos_ntp_global.py
index 9aac605..c536141 100644
--- a/tests/unit/modules/test_vyos_ntp_global.py
+++ b/tests/unit/modules/test_vyos_ntp_global.py
@@ -4,13 +4,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+import json
import os
-import sys
import unittest
-
-# Allow importing collection modules without full ansible-test runner
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
+from unittest.mock import MagicMock
from ansible_collections.vyos.rest.plugins.modules.vyos_ntp_global import (
build_commands,
@@ -19,7 +17,21 @@ from ansible_collections.vyos.rest.plugins.modules.vyos_ntp_global import (
normalize_servers,
)
-from tests.unit.modules.base import VyOSModuleTestCase, load_fixture
+
+def load_fixture(filename):
+ fixtures_dir = os.path.join(os.path.dirname(__file__), "..", "fixtures")
+ path = os.path.join(fixtures_dir, filename)
+ with open(path) as f:
+ return json.load(f)
+
+
+class VyOSModuleTestCase(unittest.TestCase):
+ def setUp(self):
+ self.mock_vyos = MagicMock()
+ self.mock_vyos.get_config = MagicMock(return_value={})
+
+ def set_running_config(self, data):
+ self.mock_vyos.get_config.return_value = data
class TestVyOSNtpGlobalNormalize(unittest.TestCase):
diff --git a/tests/unit/modules/test_vyos_route_maps.py b/tests/unit/modules/test_vyos_route_maps.py
index 2d45bb7..97d814b 100644
--- a/tests/unit/modules/test_vyos_route_maps.py
+++ b/tests/unit/modules/test_vyos_route_maps.py
@@ -4,12 +4,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+import json
import os
-import sys
import unittest
-
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
+from unittest.mock import MagicMock
from ansible_collections.vyos.rest.plugins.modules.vyos_route_maps import (
_want_to_api_match,
@@ -18,7 +17,21 @@ from ansible_collections.vyos.rest.plugins.modules.vyos_route_maps import (
get_running_config,
)
-from tests.unit.modules.base import VyOSModuleTestCase, load_fixture
+
+def load_fixture(filename):
+ fixtures_dir = os.path.join(os.path.dirname(__file__), "..", "fixtures")
+ path = os.path.join(fixtures_dir, filename)
+ with open(path) as f:
+ return json.load(f)
+
+
+class VyOSModuleTestCase(unittest.TestCase):
+ def setUp(self):
+ self.mock_vyos = MagicMock()
+ self.mock_vyos.get_config = MagicMock(return_value={})
+
+ def set_running_config(self, data):
+ self.mock_vyos.get_config.return_value = data
class TestVyOSRouteMapsGetRunning(VyOSModuleTestCase):