Skip to content

Commit

Permalink
Fix help output (#175)
Browse files Browse the repository at this point in the history
* fix: Don't display error if line is empty at base classes do_default

* fix: TOOLS-2570 cluster_key is displayed as `inf`
This happens when the cluster key is a parsable float like `1463E6705933`
where the E denotes engineering notation.

* fix: `manage create role` help usage displays extra role
  • Loading branch information
jdogmcsteezy committed Jun 30, 2023
1 parent 4a7ced1 commit f70f91e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
5 changes: 4 additions & 1 deletion lib/base_controller.py
Expand Up @@ -663,7 +663,10 @@ def execute_help(self, line, method=None) -> str:
async def _do_default(self, line):
# Override method to provide default command behavior
self.view.print_result(self.execute_help(line))
raise ShellException("%s: command not found." % (" ".join(line)))

if line:
# It is only an error if there is still something left to be parsed
raise ShellException("%s: command not found." % (" ".join(line)))

def pre_command(self, line):
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/live_cluster/manage_controller.py
Expand Up @@ -511,7 +511,7 @@ async def _supports_quotas(self, nodes):

@CommandHelp(
"Create a role",
usage="role <role-name> priv <privilege> [ns <namespace> [set <set>]] [allow <addr1> [<addr2> [...]]] [read <read-quota>] [write <write-quota>]",
usage="<role-name> priv <privilege> [ns <namespace> [set <set>]] [allow <addr1> [<addr2> [...]]] [read <read-quota>] [write <write-quota>]",
modifiers=(
ModifierHelp("role", "Name of the new role."),
ModifierHelp(
Expand Down
5 changes: 3 additions & 2 deletions lib/view/sheet/render/base_rsheet.py
Expand Up @@ -14,6 +14,7 @@

from collections import OrderedDict
from itertools import groupby
import math
from operator import itemgetter

from lib.utils import util
Expand Down Expand Up @@ -337,8 +338,8 @@ def _infer_projector(self, dfield, key):
pass

try:
float(entry)
has_float = True
if float(entry) != math.inf:
has_float = True
continue
except (ValueError, TypeError):
pass
Expand Down
23 changes: 11 additions & 12 deletions test/unit/test_base_controller.py
Expand Up @@ -161,27 +161,26 @@ def test_find_method(self):
except ShellException:
self.assertEqual("ShellException", expected_method)

async def test_execute(self):
test_lines = [
([], "ShellException"),
@parameterized.expand(
[
(["fake"], "ShellException"),
(["fakea1"], "fake1"),
(["fakeb2"], "fake2"),
(["fakeb", "c"], "fake2"),
(["fakeb2", "f"], "ShellException"),
(["fakeb2", "foo"], "foo"),
]

)
async def test_execute(self, line, expected_result):
r = FakeRoot()

for line, expected_result in test_lines:
try:
actual_result = await r(line)
actual_result = actual_result[0]
except ShellException:
self.assertEqual(expected_result, "ShellException")
else:
self.assertEqual(expected_result, actual_result)
try:
actual_result = await r(line)
actual_result = actual_result[0]
except ShellException:
self.assertEqual(expected_result, "ShellException")
else:
self.assertEqual(expected_result, actual_result)

@parameterized.expand(
[
Expand Down

0 comments on commit f70f91e

Please sign in to comment.