1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-23 07:20:55 +03:00

Document and test start_listener() return value

This commit is contained in:
Seth Schoen
2015-02-09 10:00:01 -08:00
parent 470cad14ad
commit 275d3e3da5
2 changed files with 7 additions and 1 deletions

View File

@@ -191,6 +191,8 @@ class StandaloneAuthenticator(object):
:param int port: The TCP port to bind.
:param str key: The private key to use (in PEM format).
:returns: True or False to indicate success or failure creating
the subprocess.
"""
fork_result = os.fork()
Crypto.Random.atfork()

View File

@@ -261,8 +261,12 @@ class StartListenerTest(unittest.TestCase):
@mock.patch("letsencrypt.client.standalone_authenticator.os.fork")
def test_start_listener_fork_parent(self, mock_fork, mock_atfork):
self.authenticator.do_parent_process = mock.Mock()
self.authenticator.do_parent_process.return_value = True
mock_fork.return_value = 22222
self.authenticator.start_listener(1717, "key")
result = self.authenticator.start_listener(1717, "key")
# start_listener is expected to return the True or False return
# value from do_parent_process.
self.assertTrue(result)
self.assertEqual(self.authenticator.child_pid, 22222)
self.authenticator.do_parent_process.assert_called_once_with(1717)
mock_atfork.assert_called_once_with()