From: Douglas Bagnall Date: Thu, 30 Jan 2025 08:22:53 +0000 (+1300) Subject: pytest: samba-tool --version tests X-Git-Tag: tevent-0.17.0~857 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd59b316b80eac6fc1c2e62193995adc09d099cd;p=thirdparty%2Fsamba.git pytest: samba-tool --version tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770 Signed-off-by: Douglas Bagnall Reviewed-by: Jennifer Sutton --- diff --git a/python/samba/tests/samba_tool/help.py b/python/samba/tests/samba_tool/help.py index 16eb6b74c5d..3459dd21619 100644 --- a/python/samba/tests/samba_tool/help.py +++ b/python/samba/tests/samba_tool/help.py @@ -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 index 00000000000..4187c179dbc --- /dev/null +++ b/selftest/knownfail.d/samba-tool--version @@ -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\)