forked from certbot/certbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: miscellaneous IReporter removals (certbot#8436)
* certbot delete: use undecorated print * certbot revoke: use undecorated print * certbot revoke: remove ireporter usages * eff: remove IReporter usages * certbot unregister: remove IReporter usage * certbot update_account: remove IReporter usages * certbot run: remove IReporter in duplicate prompt * fix test_revoke_multiple_lineages
- Loading branch information
Showing
9 changed files
with
59 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,23 +339,23 @@ def _call(self, mock_config): | |
from certbot._internal.main import _delete_if_appropriate | ||
_delete_if_appropriate(mock_config) | ||
|
||
def _test_delete_opt_out_common(self, mock_get_utility): | ||
def _test_delete_opt_out_common(self): | ||
with mock.patch('certbot._internal.cert_manager.delete') as mock_delete: | ||
self._call(self.config) | ||
mock_delete.assert_not_called() | ||
self.assertTrue(mock_get_utility().add_message.called) | ||
|
||
@test_util.patch_get_utility() | ||
def test_delete_flag_opt_out(self, mock_get_utility): | ||
def test_delete_flag_opt_out(self, unused_mock_get_utility): | ||
self.config.delete_after_revoke = False | ||
self._test_delete_opt_out_common(mock_get_utility) | ||
self._test_delete_opt_out_common() | ||
|
||
@test_util.patch_get_utility() | ||
def test_delete_prompt_opt_out(self, mock_get_utility): | ||
util_mock = mock_get_utility() | ||
util_mock.yesno.return_value = False | ||
self._test_delete_opt_out_common(mock_get_utility) | ||
self._test_delete_opt_out_common() | ||
|
||
@mock.patch("certbot._internal.main.logger.warning") | ||
@mock.patch('certbot._internal.storage.renewal_file_for_certname') | ||
@mock.patch('certbot._internal.cert_manager.delete') | ||
@mock.patch('certbot._internal.cert_manager.match_and_check_overlaps') | ||
|
@@ -365,7 +365,7 @@ def test_delete_prompt_opt_out(self, mock_get_utility): | |
def test_overlapping_archive_dirs(self, mock_get_utility, | ||
mock_cert_path_to_lineage, mock_archive, | ||
mock_match_and_check_overlaps, mock_delete, | ||
mock_renewal_file_for_certname): | ||
mock_renewal_file_for_certname, mock_warning): | ||
# pylint: disable = unused-argument | ||
config = self.config | ||
config.cert_path = "/some/reasonable/path" | ||
|
@@ -374,6 +374,7 @@ def test_overlapping_archive_dirs(self, mock_get_utility, | |
mock_match_and_check_overlaps.side_effect = errors.OverlappingMatchFound() | ||
self._call(config) | ||
mock_delete.assert_not_called() | ||
self.assertEqual(mock_warning.call_count, 1) | ||
|
||
@mock.patch('certbot._internal.storage.renewal_file_for_certname') | ||
@mock.patch('certbot._internal.cert_manager.match_and_check_overlaps') | ||
|
@@ -1448,9 +1449,10 @@ def test_update_account_remove_email(self, mocked_account_module, mock_prepare, | |
# ensure we didn't try to subscribe (no email to subscribe with) | ||
self.assertFalse(mock_prepare.called) | ||
|
||
@mock.patch("certbot._internal.main.display_util.notify") | ||
@mock.patch('certbot._internal.main.display_ops.get_email') | ||
@test_util.patch_get_utility() | ||
def test_update_account_with_email(self, mock_utility, mock_email): | ||
def test_update_account_with_email(self, mock_utility, mock_email, mock_notify): | ||
email = "[email protected]" | ||
mock_email.return_value = email | ||
with mock.patch('certbot._internal.eff.prepare_subscription') as mock_prepare: | ||
|
@@ -1475,7 +1477,7 @@ def test_update_account_with_email(self, mock_utility, mock_email): | |
# and we saved the updated registration on disk | ||
self.assertTrue(mocked_storage.update_regr.called) | ||
self.assertTrue( | ||
email in mock_utility().add_message.call_args[0][0]) | ||
email in mock_notify.call_args[0][0]) | ||
self.assertTrue(mock_prepare.called) | ||
|
||
@mock.patch('certbot._internal.plugins.selection.choose_configurator_plugins') | ||
|
@@ -1517,7 +1519,8 @@ def test_abort_unregister(self): | |
res = main.unregister(config, unused_plugins) | ||
self.assertEqual(res, "Deactivation aborted.") | ||
|
||
def test_unregister(self): | ||
@mock.patch("certbot._internal.main.display_util.notify") | ||
def test_unregister(self, mock_notify): | ||
mocked_storage = mock.MagicMock() | ||
mocked_storage.find_all.return_value = ["an account"] | ||
|
||
|
@@ -1533,9 +1536,7 @@ def test_unregister(self): | |
res = main.unregister(config, unused_plugins) | ||
|
||
self.assertTrue(res is None) | ||
self.assertTrue(cb_client.acme.deactivate_registration.called) | ||
m = "Account deactivated." | ||
self.assertTrue(m in self.mocks['get_utility']().add_message.call_args[0][0]) | ||
mock_notify.assert_called_once_with("Account deactivated.") | ||
|
||
def test_unregister_no_account(self): | ||
mocked_storage = mock.MagicMock() | ||
|