Skip to content

fix: Handle cms command raising error #8054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cms/management/commands/subcommands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def create_parser(self, prog_name, subcommand):
parser = CommandParser(
prog=f"{os.path.basename(prog_name)} {subcommand}",
description=self.help or None,
missing_args_message=getattr(self, "missing_args_message", None),
called_from_command_line=getattr(self, "_called_from_command_line", None),
**kwargs
)
self.add_arguments(parser)
Expand Down
4 changes: 4 additions & 0 deletions cms/tests/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def test_uninstall_plugins_with_plugin(self):
self.assertEqual(out.getvalue(), "1 'TextPlugin' plugins uninstalled\n")
self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 0)

def test_for_running_only_cms_command(self):
with self.assertRaises(CommandError) as e:
management.call_command('cms')
self.assertEqual(str(e.exception), 'Error: one of the available sub commands must be provided')

class PageFixtureManagementTestCase(NavextendersFixture, CMSTestCase):

Expand Down