From aff435a0fb3a56b1d7b738c7dede363440884b3a Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 17 Sep 2026 15:05:36 +0100 Subject: Add the Canonical laptop profile and setup workflows --- tests/test_canonical_profiles.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_canonical_profiles.py (limited to 'tests/test_canonical_profiles.py') diff --git a/tests/test_canonical_profiles.py b/tests/test_canonical_profiles.py new file mode 100644 index 0000000..e066661 --- /dev/null +++ b/tests/test_canonical_profiles.py @@ -0,0 +1,33 @@ +import tempfile +import unittest +from pathlib import Path + +from scripts.canonical_profiles import preferences, profiles + + +class ProfileTests(unittest.TestCase): + def test_preferences_preserve_user_lines_and_are_idempotent(self): + original = 'user_pref("local.setting", true);\n' + owned = 'user_pref("mail.biff.show_alert", true);\n' + result = preferences(original, owned) + self.assertIn(original, result) + self.assertEqual(preferences(result, owned), result) + self.assertNotIn("show_alert", preferences(result, "")) + + def test_incomplete_marker_is_not_overwritten(self): + with self.assertRaises(ValueError): + preferences("// dotfiles: begin\nlocal data", "") + + def test_profile_paths_stay_inside_the_snap_directory(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "work@canonical.com").mkdir() + (root / "profiles.ini").write_text( + "[Profile0]\nPath=work@canonical.com\nIsRelative=1\n" + "[Profile1]\nPath=/etc\nIsRelative=0\n" + ) + self.assertEqual(profiles(root), [root / "work@canonical.com"]) + + +if __name__ == "__main__": + unittest.main() -- cgit v1.3.1