OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
certbot
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📄
__init__.py
20 bytes
02/07/2019 09:20:30 PM
rw-r--r--
📁
__pycache__
-
05/25/2021 01:14:27 PM
rwxr-xr-x
📄
account_test.py
14.45 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
acme_util.py
3.18 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
auth_handler_test.py
24 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
cert_manager_test.py
28.07 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
cli_test.py
19.94 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
client_test.py
28.76 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
compat_test.py
736 bytes
02/07/2019 09:20:30 PM
rw-r--r--
📄
configuration_test.py
6.82 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
crypto_util_test.py
13.56 KB
02/07/2019 09:20:30 PM
rw-r--r--
📁
display
-
05/25/2021 01:14:27 PM
rwxr-xr-x
📄
eff_test.py
5.94 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
error_handler_test.py
5.31 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
errors_test.py
1.8 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
hook_test.py
16.67 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
lock_test.py
3.84 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
log_test.py
14.95 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
main_test.py
82.52 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
notify_test.py
2.07 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
ocsp_test.py
6.27 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
renewal_test.py
4.18 KB
12/18/2020 08:47:58 PM
rw-r--r--
📄
renewupdater_test.py
5.32 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
reporter_test.py
2.73 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
reverter_test.py
18.7 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
storage_test.py
42.89 KB
02/07/2019 09:20:30 PM
rw-r--r--
📁
testdata
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📄
util.py
14.12 KB
02/07/2019 09:20:30 PM
rw-r--r--
📄
util_test.py
21.58 KB
02/07/2019 09:20:30 PM
rw-r--r--
Editing: reporter_test.py
Close
"""Tests for certbot.reporter.""" import mock import sys import unittest import six class ReporterTest(unittest.TestCase): """Tests for certbot.reporter.Reporter.""" def setUp(self): from certbot import reporter self.reporter = reporter.Reporter(mock.MagicMock(quiet=False)) self.old_stdout = sys.stdout # type: ignore sys.stdout = six.StringIO() def tearDown(self): sys.stdout = self.old_stdout def test_multiline_message(self): self.reporter.add_message("Line 1\nLine 2", self.reporter.LOW_PRIORITY) self.reporter.print_messages() output = sys.stdout.getvalue() # type: ignore self.assertTrue("Line 1\n" in output) self.assertTrue("Line 2" in output) def test_tty_print_empty(self): sys.stdout.isatty = lambda: True # type: ignore self.test_no_tty_print_empty() def test_no_tty_print_empty(self): self.reporter.print_messages() self.assertEqual(sys.stdout.getvalue(), "") # type: ignore try: raise ValueError except ValueError: self.reporter.print_messages() self.assertEqual(sys.stdout.getvalue(), "") # type: ignore def test_tty_successful_exit(self): sys.stdout.isatty = lambda: True # type: ignore self._successful_exit_common() def test_no_tty_successful_exit(self): self._successful_exit_common() def test_tty_unsuccessful_exit(self): sys.stdout.isatty = lambda: True # type: ignore self._unsuccessful_exit_common() def test_no_tty_unsuccessful_exit(self): self._unsuccessful_exit_common() def _successful_exit_common(self): self._add_messages() self.reporter.print_messages() output = sys.stdout.getvalue() # type: ignore self.assertTrue("IMPORTANT NOTES:" in output) self.assertTrue("High" in output) self.assertTrue("Med" in output) self.assertTrue("Low" in output) def _unsuccessful_exit_common(self): self._add_messages() try: raise ValueError except ValueError: self.reporter.print_messages() output = sys.stdout.getvalue() # type: ignore self.assertTrue("IMPORTANT NOTES:" in output) self.assertTrue("High" in output) self.assertTrue("Med" not in output) self.assertTrue("Low" not in output) def _add_messages(self): self.reporter.add_message("High", self.reporter.HIGH_PRIORITY) self.reporter.add_message( "Med", self.reporter.MEDIUM_PRIORITY, on_crash=False) self.reporter.add_message( "Low", self.reporter.LOW_PRIORITY, on_crash=False) if __name__ == "__main__": unittest.main() # pragma: no cover