From 1a386b6ef60f060460ee5d7a86488fcb9ad4bf77 Mon Sep 17 00:00:00 2001 From: Michal Reznik Date: Feb 14 2018 10:50:07 +0000 Subject: test_help: test "help" command without cache This test case addresses upsteam ticket #6999, where "ipa help" does not work if called when no schema is cached. https://pagure.io/freeipa/issue/7325 Reviewed-By: Christian Heimes --- diff --git a/ipatests/test_cmdline/test_help.py b/ipatests/test_cmdline/test_help.py index b28aa23..919e608 100644 --- a/ipatests/test_cmdline/test_help.py +++ b/ipatests/test_cmdline/test_help.py @@ -18,6 +18,9 @@ # import sys +import os +import shutil +import errno import six from six import StringIO @@ -70,6 +73,27 @@ def test_ipa_help(): assert ctx.stderr == '' +def test_ipa_help_without_cache(): + """Test `ipa help` without schema cache""" + cache_dir = os.path.expanduser('~/.cache/ipa/schema/') + backup_dir = os.path.expanduser('~/.cache/ipa/schema.bak/') + shutil.rmtree(backup_dir, ignore_errors=True) + if os.path.isdir(cache_dir): + os.rename(cache_dir, backup_dir) + try: + with CLITestContext() as ctx: + return_value = api.Backend.cli.run(['help']) + assert return_value == 0 + assert ctx.stderr == '' + finally: + shutil.rmtree(cache_dir, ignore_errors=True) + try: + os.rename(backup_dir, cache_dir) + except OSError as e: + if e.errno != errno.ENOENT: + raise + + def test_ipa_without_arguments(): """Test that `ipa` errors out, and prints the help to stderr""" with CLITestContext(exception=SystemExit) as ctx: @@ -134,6 +158,7 @@ def test_ambiguous_command_or_topic(): assert h_ctx.stdout != help_ctx.stdout + def test_multiline_description(): """Test that all of a multi-line command description appears in output """