From 275d3e3da5ebcc0b12eea45d93edbb93a930da21 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Mon, 9 Feb 2015 10:00:01 -0800 Subject: [PATCH] Document and test start_listener() return value --- letsencrypt/client/standalone_authenticator.py | 2 ++ letsencrypt/client/tests/standalone_authenticator_test.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/letsencrypt/client/standalone_authenticator.py b/letsencrypt/client/standalone_authenticator.py index afffa7cb3..fd28d3c2a 100644 --- a/letsencrypt/client/standalone_authenticator.py +++ b/letsencrypt/client/standalone_authenticator.py @@ -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() diff --git a/letsencrypt/client/tests/standalone_authenticator_test.py b/letsencrypt/client/tests/standalone_authenticator_test.py index 08312bd90..911de737a 100644 --- a/letsencrypt/client/tests/standalone_authenticator_test.py +++ b/letsencrypt/client/tests/standalone_authenticator_test.py @@ -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()