Add directory_select method to FileDisplay

This commit is contained in:
Brad Warren
2016-03-23 15:11:36 -07:00
parent 7820c687f1
commit 9d70c4acfb
2 changed files with 23 additions and 0 deletions
+14
View File
@@ -7,6 +7,7 @@ import zope.interface
from letsencrypt import interfaces
from letsencrypt import errors
from letsencrypt.display import completer
WIDTH = 72
HEIGHT = 20
@@ -339,6 +340,19 @@ class FileDisplay(object):
else:
return code, []
def directory_select(self, message, **unused_kwargs):
"""Display a directory selection screen.
:param str message: prompt to give the user
:returns: tuple of the form (`code`, `string`) where
`code` - int display exit code
`string` - input entered by the user
"""
with completer.Completer():
return self.input(message)
def _scrub_checklist_input(self, indices, tags):
# pylint: disable=no-self-use
"""Validate input and transform indices to appropriate tags.
+9
View File
@@ -232,6 +232,15 @@ class FileOutputDisplayTest(unittest.TestCase):
self.displayer._scrub_checklist_input(list_, TAGS))
self.assertEqual(set_tags, exp[i])
@mock.patch("letsencrypt.display.util.FileDisplay.input")
def test_directory_select(self, mock_input):
message = "msg"
result = (display_util.OK, "/var/www/html",)
mock_input.return_value = result
self.assertEqual(self.displayer.directory_select(message), result)
mock_input.assert_called_once_with(message)
def test_scrub_checklist_input_invalid(self):
# pylint: disable=protected-access
indices = [