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)
|
print(info)
|
||||||
else:
|
else:
|
||||||
substitutions = self._find_substitution(query)
|
substitutions = self._find_substitution(query)
|
||||||
print("Failed to find any docs for query: '%s'" % query)
|
if len(substitutions) == 1:
|
||||||
if substitutions:
|
print(self._find_info(substitutions[0]))
|
||||||
print("Did you mean one of these?\n\t%s" %
|
else:
|
||||||
"\n\t".join(substitutions))
|
print("Failed to find any docs for query: '%s'" % query)
|
||||||
return 1
|
if substitutions:
|
||||||
|
print("Did you mean one of these?\n\t%s" %
|
||||||
|
"\n\t".join(substitutions))
|
||||||
|
return 1
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
"""List main entities in Rally for which rally info find works.
|
"""List main entities in Rally for which rally info find works.
|
||||||
|
@ -54,18 +54,13 @@ class InfoTestCase(unittest.TestCase):
|
|||||||
("info find NonExistingStuff"))
|
("info find NonExistingStuff"))
|
||||||
|
|
||||||
def test_find_misspelling_typos(self):
|
def test_find_misspelling_typos(self):
|
||||||
marker_string = "ExistingServers"
|
marker_string = "ExistingServers (server provider)."
|
||||||
try:
|
self.assertIn(marker_string, self.rally("info find ExistinfServert"))
|
||||||
self.rally("info find ExistinfServert")
|
|
||||||
except utils.RallyCmdError as e:
|
|
||||||
self.assertIn(marker_string, e.output)
|
|
||||||
|
|
||||||
def test_find_misspelling_truncated(self):
|
def test_find_misspelling_truncated(self):
|
||||||
marker_string = "boot_and_delete_server"
|
marker_string = ("NovaServers.boot_and_delete_server "
|
||||||
try:
|
"(benchmark scenario).")
|
||||||
self.rally("info find boot_and_delete")
|
self.assertIn(marker_string, self.rally("info find boot_and_delete"))
|
||||||
except utils.RallyCmdError as e:
|
|
||||||
self.assertIn(marker_string, e.output)
|
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
output = self.rally("info list")
|
output = self.rally("info list")
|
||||||
|
Loading…
Reference in New Issue
Block a user