summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@sommerfeld.dev>2026-09-22 14:14:52 +0100
committersommerfeld <sommerfeld@sommerfeld.dev>2026-09-22 14:14:52 +0100
commit05bf213010f4a09487c1bb67e73e61bd31bb33b7 (patch)
treee6d42ca099dec3186db25954568149a8f7e368be /tests
parent5682899d6bf944f6f09e1c055b61052335d2c3e0 (diff)
downloaddotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.tar.gz
dotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.tar.bz2
dotfiles-05bf213010f4a09487c1bb67e73e61bd31bb33b7.zip
Find bond source profiles through NetworkManager
Diffstat (limited to 'tests')
-rw-r--r--tests/test_canonical_bond.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_canonical_bond.py b/tests/test_canonical_bond.py
index d9f097c..d3505cb 100644
--- a/tests/test_canonical_bond.py
+++ b/tests/test_canonical_bond.py
@@ -1,12 +1,37 @@
import shutil
import subprocess
+import tempfile
import unittest
+from pathlib import Path
from unittest.mock import patch
from scripts import canonical_bond as bond
class BondTests(unittest.TestCase):
+ def test_profile_source_uses_reported_filename_without_embedded_uuid(self):
+ with tempfile.TemporaryDirectory() as directory:
+ path = Path(directory) / "netplan wired:profile.nmconnection"
+ source = "[connection]\nid=netplan-ethernet\ntype=ethernet\n"
+ path.write_text(source)
+ with (
+ patch.object(
+ bond, "nmcli", return_value=f"other:/missing\nidentity:{path}"
+ ) as command,
+ patch.object(Path, "glob", return_value=[]),
+ ):
+ self.assertEqual(bond.profile_source("identity"), source)
+ command.assert_called_once_with(
+ "--escape", "no", "-g", "UUID,FILENAME", "connection", "show"
+ )
+
+ def test_profile_source_rejects_missing_filename(self):
+ with (
+ patch.object(bond, "nmcli", return_value="identity:"),
+ self.assertRaisesRegex(ValueError, "No saved"),
+ ):
+ bond.profile_source("identity")
+
@unittest.skipUnless(shutil.which("nmcli"), "nmcli is in the Nix development shell")
def test_networkmanager_accepts_offline_profiles(self):
config = bond.keyfile(bond.bond_profile())