mirror of
https://github.com/certbot/certbot.git
synced 2026-08-04 12:13:34 +02:00
Add directory_select to NoninteractiveDisplay
This commit is contained in:
@@ -555,6 +555,23 @@ class NoninteractiveDisplay(object):
|
|||||||
else:
|
else:
|
||||||
return OK, default
|
return OK, default
|
||||||
|
|
||||||
|
def directory_select(self, message, default=None, cli_flag=None):
|
||||||
|
"""Simulate prompting the user for a directory.
|
||||||
|
|
||||||
|
This function returns default if it is not ``None``, otherwise,
|
||||||
|
an exception is raised.
|
||||||
|
|
||||||
|
:param str message: prompt to give the user
|
||||||
|
:param default: default value to return (if one exists)
|
||||||
|
:param str cli_flag: option used to set this value with the CLI
|
||||||
|
|
||||||
|
:returns: tuple of the form (`code`, `string`) where
|
||||||
|
`code` - int display exit code
|
||||||
|
`string` - input entered by the user
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self.input(message, default, cli_flag)
|
||||||
|
|
||||||
|
|
||||||
def separate_list_input(input_):
|
def separate_list_input(input_):
|
||||||
"""Separate a comma or space separated list.
|
"""Separate a comma or space separated list.
|
||||||
|
|||||||
@@ -335,6 +335,15 @@ class NoninteractiveDisplayTest(unittest.TestCase):
|
|||||||
self.assertEqual(ret, (display_util.OK, d))
|
self.assertEqual(ret, (display_util.OK, d))
|
||||||
self.assertRaises(errors.MissingCommandlineFlag, self.displayer.checklist, "message", TAGS)
|
self.assertRaises(errors.MissingCommandlineFlag, self.displayer.checklist, "message", TAGS)
|
||||||
|
|
||||||
|
def test_directory_select(self):
|
||||||
|
default = "/var/www/html"
|
||||||
|
expected = (display_util.OK, default)
|
||||||
|
actual = self.displayer.directory_select("msg", default)
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
self.assertRaises(
|
||||||
|
errors.MissingCommandlineFlag, self.displayer.directory_select, "msg")
|
||||||
|
|
||||||
|
|
||||||
class SeparateListInputTest(unittest.TestCase):
|
class SeparateListInputTest(unittest.TestCase):
|
||||||
"""Test Module functions."""
|
"""Test Module functions."""
|
||||||
|
|||||||
Reference in New Issue
Block a user