]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest: samba-tool --version tests
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 30 Jan 2025 08:22:53 +0000 (21:22 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Sat, 8 Feb 2025 02:33:38 +0000 (02:33 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
python/samba/tests/samba_tool/help.py
selftest/knownfail.d/samba-tool--version [new file with mode: 0644]

index 16eb6b74c5d3c1c298b4067a195029473748804f..3459dd21619774a69513998c54a261667a005301 100644 (file)
@@ -22,6 +22,7 @@ from samba.tests.samba_tool.base import SambaToolCmdTest
 from samba.tests import BlackboxProcessError
 from samba.tests import check_help_consistency
 from samba.common import get_string
+from samba import version
 
 
 class HelpTestCase(SambaToolCmdTest):
@@ -88,3 +89,33 @@ class HelpTestCase(SambaToolCmdTest):
                                                "pleeease"])
         self.assertIn("if '--pass-the-salt-please' is not misspelt", err)
         self.assertIn("the appropriate list in is_password_option", err)
+
+    def test_version(self):
+        """Does --version work?"""
+        (result, out, err) = self.run_command(["samba-tool", "--version"])
+        self.assertEqual(version, out.strip())
+
+    def test_sub_command_version(self):
+        """Does --version work in a sub-command?"""
+        (result, out, err) = self.run_command(["samba-tool", "spn", "--version"])
+        self.assertEqual(version, out.strip())
+
+    def test_leaf_command_version(self):
+        """Does --version work in a leaf command?"""
+        (result, out, err) = self.run_command(["samba-tool", "contact", "edit",
+                                               "--version"])
+        self.assertEqual(version, out.strip())
+
+    def test_help_version(self):
+        """Is version mentioned in --help?"""
+        (result, out, err) = self.run_command(["samba-tool", "spn", "--help"])
+        self.assertIn(version, out)
+
+    def test_version_beats_help(self):
+        """Does samba-tool --help --version print version?"""
+        (result, out, err) = self.run_command(["samba-tool", "spn", "--help", "-V"])
+        self.assertEqual(version, out.strip())
+        (result, out, err) = self.run_command(["samba-tool", "--help", "-V"])
+        self.assertEqual(version, out.strip())
+        (result, out, err) = self.run_command(["samba-tool", "dns", "-V", "--help"])
+        self.assertEqual(version, out.strip())
diff --git a/selftest/knownfail.d/samba-tool--version b/selftest/knownfail.d/samba-tool--version
new file mode 100644 (file)
index 0000000..4187c17
--- /dev/null
@@ -0,0 +1,8 @@
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(none\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_sub_command_version\(none\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version\(none\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(none\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(fileserver\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_sub_command_version\(fileserver\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version\(fileserver\)
+^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(fileserver\)