mirror of
https://github.com/certbot/certbot.git
synced 2026-01-26 07:41:33 +03:00
Move items in certbot/display to _internal (#7532)
* Move display/completer.py to _internal/ * Move display/dummy_readline.py to _internal/ * Move display/enhancements.py to _internal/ * Create __init__.py in _internal/display
This commit is contained in:
@@ -30,7 +30,7 @@ from certbot import interfaces
|
||||
from certbot._internal import storage
|
||||
from certbot import util
|
||||
from certbot.compat import os
|
||||
from certbot.display import enhancements
|
||||
from certbot._internal.display import enhancements
|
||||
from certbot.display import ops as display_ops
|
||||
from certbot.plugins import selection as plugin_selection
|
||||
|
||||
|
||||
1
certbot/_internal/display/__init__.py
Normal file
1
certbot/_internal/display/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Certbot display utilities."""
|
||||
@@ -4,7 +4,7 @@ import glob
|
||||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
import certbot.display.dummy_readline as readline # type: ignore
|
||||
import certbot._internal.display.dummy_readline as readline # type: ignore
|
||||
|
||||
|
||||
class Completer(object):
|
||||
@@ -10,7 +10,7 @@ from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot.compat import misc
|
||||
from certbot.compat import os
|
||||
from certbot.display import completer
|
||||
from certbot._internal.display import completer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Test certbot.display.completer."""
|
||||
"""Test certbot._internal.display.completer."""
|
||||
try:
|
||||
import readline # pylint: disable=import-error
|
||||
except ImportError:
|
||||
import certbot.display.dummy_readline as readline # type: ignore
|
||||
import certbot._internal.display.dummy_readline as readline # type: ignore
|
||||
import string
|
||||
import sys
|
||||
import unittest
|
||||
@@ -18,7 +18,7 @@ import certbot.tests.util as test_util # pylint: disable=ungrouped-imports
|
||||
|
||||
|
||||
class CompleterTest(test_util.TempDirTestCase):
|
||||
"""Test certbot.display.completer.Completer."""
|
||||
"""Test certbot._internal.display.completer.Completer."""
|
||||
|
||||
def setUp(self):
|
||||
super(CompleterTest, self).setUp()
|
||||
@@ -40,7 +40,7 @@ class CompleterTest(test_util.TempDirTestCase):
|
||||
pass
|
||||
|
||||
def test_complete(self):
|
||||
from certbot.display import completer
|
||||
from certbot._internal.display import completer
|
||||
my_completer = completer.Completer()
|
||||
num_paths = len(self.paths)
|
||||
|
||||
@@ -64,7 +64,7 @@ class CompleterTest(test_util.TempDirTestCase):
|
||||
sys.modules['readline'] = original_readline
|
||||
|
||||
def test_context_manager_with_unmocked_readline(self):
|
||||
from certbot.display import completer
|
||||
from certbot._internal.display import completer
|
||||
reload_module(completer)
|
||||
|
||||
original_completer = readline.get_completer()
|
||||
@@ -76,18 +76,18 @@ class CompleterTest(test_util.TempDirTestCase):
|
||||
self.assertEqual(readline.get_completer(), original_completer)
|
||||
self.assertEqual(readline.get_completer_delims(), original_delims)
|
||||
|
||||
@mock.patch('certbot.display.completer.readline', autospec=True)
|
||||
@mock.patch('certbot._internal.display.completer.readline', autospec=True)
|
||||
def test_context_manager_libedit(self, mock_readline):
|
||||
mock_readline.__doc__ = 'libedit'
|
||||
self._test_context_manager_with_mock_readline(mock_readline)
|
||||
|
||||
@mock.patch('certbot.display.completer.readline', autospec=True)
|
||||
@mock.patch('certbot._internal.display.completer.readline', autospec=True)
|
||||
def test_context_manager_readline(self, mock_readline):
|
||||
mock_readline.__doc__ = 'GNU readline'
|
||||
self._test_context_manager_with_mock_readline(mock_readline)
|
||||
|
||||
def _test_context_manager_with_mock_readline(self, mock_readline):
|
||||
from certbot.display import completer
|
||||
from certbot._internal.display import completer
|
||||
|
||||
mock_readline.parse_and_bind.side_effect = enable_tab_completion
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ class AskTest(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def _call(cls, enhancement):
|
||||
from certbot.display.enhancements import ask
|
||||
from certbot._internal.display.enhancements import ask
|
||||
return ask(enhancement)
|
||||
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
@mock.patch("certbot._internal.display.enhancements.util")
|
||||
def test_redirect(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 1)
|
||||
self.assertTrue(self._call("redirect"))
|
||||
@@ -34,20 +34,20 @@ class RedirectTest(unittest.TestCase):
|
||||
"""Test the redirect_by_default method."""
|
||||
@classmethod
|
||||
def _call(cls):
|
||||
from certbot.display.enhancements import redirect_by_default
|
||||
from certbot._internal.display.enhancements import redirect_by_default
|
||||
return redirect_by_default()
|
||||
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
@mock.patch("certbot._internal.display.enhancements.util")
|
||||
def test_secure(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 1)
|
||||
self.assertTrue(self._call())
|
||||
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
@mock.patch("certbot._internal.display.enhancements.util")
|
||||
def test_cancel(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 1)
|
||||
self.assertFalse(self._call())
|
||||
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
@mock.patch("certbot._internal.display.enhancements.util")
|
||||
def test_easy(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 0)
|
||||
self.assertFalse(self._call())
|
||||
|
||||
@@ -15,9 +15,3 @@
|
||||
|
||||
.. automodule:: certbot.display.ops
|
||||
:members:
|
||||
|
||||
:mod:`certbot.display.enhancements`
|
||||
=======================================
|
||||
|
||||
.. automodule:: certbot.display.enhancements
|
||||
:members:
|
||||
|
||||
Reference in New Issue
Block a user