rally info: smart substitutions in the non-ambiguous case
When the user inputs his query just with a couple of typos, however, there is typically only one substitution suggested by the system: $ rally info find NovaServers.boot_and_delete_servers Failed to find any docs for query: 'NovaServers.boot_and_delete_servers' Did you mean one of these? NovaServers.boot_and_delete_server The idea is that in this case, when there is only one possible substitution, we could perform this substitution automatically, whithout requesting the user to do so. In the example above, Rally could response exactly as if the user typed the correct query (which is NovaServers.boot_and_delete_server, without “s” at the end): $ rally info find NovaServers.boot_and_delete_servers NovaServers.boot_and_delete_server (benchmark scenario). Tests booting and then deleting an image. Change-Id: Ie2f8ff52e21c038ce72a77299de063d7ffddf24b
This commit is contained in:
parent
28da80dcac
commit
b7032382a7
@ -87,11 +87,14 @@ class InfoCommands(object):
|
||||
print(info)
|
||||
else:
|
||||
substitutions = self._find_substitution(query)
|
||||
print("Failed to find any docs for query: '%s'" % query)
|
||||
if substitutions:
|
||||
print("Did you mean one of these?\n\t%s" %
|
||||
"\n\t".join(substitutions))
|
||||
return 1
|
||||
if len(substitutions) == 1:
|
||||
print(self._find_info(substitutions[0]))
|
||||
else:
|
||||
print("Failed to find any docs for query: '%s'" % query)
|
||||
if substitutions:
|
||||
print("Did you mean one of these?\n\t%s" %
|
||||
"\n\t".join(substitutions))
|
||||
return 1
|
||||
|
||||
def list(self):
|
||||
"""List main entities in Rally for which rally info find works.
|
||||
|
@ -54,18 +54,13 @@ class InfoTestCase(unittest.TestCase):
|
||||
("info find NonExistingStuff"))
|
||||
|
||||
def test_find_misspelling_typos(self):
|
||||
marker_string = "ExistingServers"
|
||||
try:
|
||||
self.rally("info find ExistinfServert")
|
||||
except utils.RallyCmdError as e:
|
||||
self.assertIn(marker_string, e.output)
|
||||
marker_string = "ExistingServers (server provider)."
|
||||
self.assertIn(marker_string, self.rally("info find ExistinfServert"))
|
||||
|
||||
def test_find_misspelling_truncated(self):
|
||||
marker_string = "boot_and_delete_server"
|
||||
try:
|
||||
self.rally("info find boot_and_delete")
|
||||
except utils.RallyCmdError as e:
|
||||
self.assertIn(marker_string, e.output)
|
||||
marker_string = ("NovaServers.boot_and_delete_server "
|
||||
"(benchmark scenario).")
|
||||
self.assertIn(marker_string, self.rally("info find boot_and_delete"))
|
||||
|
||||
def test_list(self):
|
||||
output = self.rally("info list")
|
||||
|
Loading…
Reference in New Issue
Block a user