From 2c40cc77fb5175f5753f943a6696b37a8ae1f6c4 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Wed, 3 Jun 2015 12:06:51 -0700 Subject: [PATCH] Added atexit_print_messages test --- letsencrypt/tests/client_test.py | 4 +++- letsencrypt/tests/reporter_test.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/letsencrypt/tests/client_test.py b/letsencrypt/tests/client_test.py index cfcee5b05..1fb9c2a03 100644 --- a/letsencrypt/tests/client_test.py +++ b/letsencrypt/tests/client_test.py @@ -38,6 +38,7 @@ class ClientTest(unittest.TestCase): @mock.patch("letsencrypt.client.zope.component.getUtility") def test_report_new_account(self, mock_zope): + # pylint: disable=protected-access self.config.config_dir = "/usr/bin/coffee" self.account.recovery_token = "ECCENTRIC INVISIBILITY RHINOCEROS" self.account.email = "rhino@jungle.io" @@ -50,6 +51,7 @@ class ClientTest(unittest.TestCase): @mock.patch("letsencrypt.client.zope.component.getUtility") def test_report_renewal_status(self, mock_zope): + # pylint: disable=protected-access cert = mock.MagicMock() cert.configuration = configobj.ConfigObj() cert.configuration["renewal_configs_dir"] = "/etc/letsencrypt/configs" @@ -66,7 +68,7 @@ class ClientTest(unittest.TestCase): msg = mock_zope().add_message.call_args[0][0] self.assertTrue("deployment but not automatic renewal" in msg) self.assertTrue(cert.configuration["renewal_configs_dir"] in msg) - + cert.configuration["autodeploy"] = "False" self.client._report_renewal_status(cert) msg = mock_zope().add_message.call_args[0][0] diff --git a/letsencrypt/tests/reporter_test.py b/letsencrypt/tests/reporter_test.py index e6a8c9005..2248e7caf 100644 --- a/letsencrypt/tests/reporter_test.py +++ b/letsencrypt/tests/reporter_test.py @@ -30,6 +30,15 @@ class ReporterTest(unittest.TestCase): self.reporter.print_messages() self.assertEqual(sys.stdout.getvalue(), "") + def test_atexit_print_messages(self): + self._add_messages() + self.reporter.atexit_print_messages() + output = sys.stdout.getvalue() + self.assertTrue("IMPORTANT NOTES:" in output) + self.assertTrue("High" in output) + self.assertTrue("Med" in output) + self.assertTrue("Low" in output) + def test_tty_successful_exit(self): sys.stdout.isatty = lambda: True self._successful_exit_common()