diff options
author | Antoine Wacheux <awacheux@bloomberg.net> | 2017-11-09 10:15:45 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-11-19 02:23:42 +0900 |
commit | d05f0f433979a6ae79667bb51d4a7a5f365941d6 (patch) | |
tree | d8c4e344a8e832b4360223df23f160741cdad949 /tests | |
parent | 0214e4c5be01412466c19be83e6b97bc0a441f26 (diff) | |
download | buildstream-d05f0f433979a6ae79667bb51d4a7a5f365941d6.tar.gz |
Accept the first character as shortcut on interruption prompts
On interruption, this makes buildstream to accept the first character of all
the possible choices as if it was the full command. This behavior has been
added to the failure screen and to the interruption screen.
Fixes https://gitlab.com/BuildStream/buildstream/issues/130
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/main.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/frontend/main.py b/tests/frontend/main.py new file mode 100644 index 000000000..9ba552c60 --- /dev/null +++ b/tests/frontend/main.py @@ -0,0 +1,34 @@ +from buildstream._frontend.main import prefix_choice_value_proc + +import pytest +import click + + +def test_prefix_choice_value_proc_full_match(): + value_proc = prefix_choice_value_proc(['foo', 'bar', 'baz']) + + assert("foo" == value_proc("foo")) + assert("bar" == value_proc("bar")) + assert("baz" == value_proc("baz")) + + +def test_prefix_choice_value_proc_prefix_match(): + value_proc = prefix_choice_value_proc(['foo']) + + assert ("foo" == value_proc("f")) + + +def test_prefix_choice_value_proc_ambigous_match(): + value_proc = prefix_choice_value_proc(['bar', 'baz']) + + assert ("bar" == value_proc("bar")) + assert ("baz" == value_proc("baz")) + with pytest.raises(click.UsageError): + value_proc("ba") + + +def test_prefix_choice_value_proc_value_not_in_choices(): + value_proc = prefix_choice_value_proc(['bar', 'baz']) + + with pytest.raises(click.UsageError): + value_proc("foo") |