mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 08:09:10 +02:00
Add directory_select method to FileDisplay
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user