1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

Move eff.py to _internal (#7530)

* Move eff.py to _internal

* missed a few certbot.effs in tests

* remove sublime autocompletion

* fix messy scripting
This commit is contained in:
ohemorange
2019-11-11 10:20:05 -08:00
committed by Brad Warren
parent e38aa65cae
commit d290fe464e
7 changed files with 25 additions and 30 deletions

View File

@@ -23,7 +23,7 @@ from certbot._internal import auth_handler
from certbot import cli
from certbot import constants
from certbot import crypto_util
from certbot import eff
from certbot._internal import eff
from certbot._internal import error_handler
from certbot import errors
from certbot import interfaces

View File

@@ -21,7 +21,7 @@ from certbot._internal import client
from certbot import configuration
from certbot import constants
from certbot import crypto_util
from certbot import eff
from certbot._internal import eff
from certbot import errors
from certbot import hooks
from certbot import interfaces

View File

@@ -89,7 +89,7 @@ class RegisterTest(test_util.ConfigTestCase):
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client.new_account_and_tos().terms_of_service = "http://tos"
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.account.report_new_account"):
mock_client().new_account_and_tos.side_effect = errors.Error
self.assertRaises(errors.Error, self._call)
@@ -103,7 +103,7 @@ class RegisterTest(test_util.ConfigTestCase):
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot._internal.account.report_new_account"):
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
self._call()
@mock.patch("certbot._internal.account.report_new_account")
@@ -115,7 +115,7 @@ class RegisterTest(test_util.ConfigTestCase):
mx_err = messages.Error.with_code('invalidContact', detail=msg)
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.eff.handle_subscription") as mock_handle:
mock_client().new_account_and_tos.side_effect = [mx_err, mock.MagicMock()]
self._call()
self.assertEqual(mock_get_email.call_count, 1)
@@ -129,7 +129,7 @@ class RegisterTest(test_util.ConfigTestCase):
mx_err = messages.Error.with_code('invalidContact', detail=msg)
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
mock_client().new_account_and_tos.side_effect = [mx_err, mock.MagicMock()]
self.assertRaises(errors.Error, self._call)
@@ -139,7 +139,7 @@ class RegisterTest(test_util.ConfigTestCase):
@mock.patch("certbot._internal.client.logger")
def test_without_email(self, mock_logger):
with mock.patch("certbot.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_clnt:
mock_clnt().external_account_required.side_effect = self._false_mock
with mock.patch("certbot._internal.account.report_new_account"):
@@ -156,7 +156,7 @@ class RegisterTest(test_util.ConfigTestCase):
"""Tests dry-run for no staging account, expect account created with no email"""
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
with mock.patch("certbot._internal.account.report_new_account"):
self.config.dry_run = True
self._call()
@@ -171,7 +171,7 @@ class RegisterTest(test_util.ConfigTestCase):
side_effect=self._new_acct_dir_mock
)
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
target = "certbot._internal.client.messages.ExternalAccountBinding.from_data"
with mock.patch(target) as mock_eab_from_data:
self.config.eab_kid = "test-kid"
@@ -183,7 +183,7 @@ class RegisterTest(test_util.ConfigTestCase):
def test_without_eab_arguments(self):
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
target = "certbot._internal.client.messages.ExternalAccountBinding.from_data"
with mock.patch(target) as mock_eab_from_data:
self.config.eab_kid = None
@@ -196,7 +196,7 @@ class RegisterTest(test_util.ConfigTestCase):
with mock.patch("certbot._internal.client.acme_client.BackwardsCompatibleClientV2") as mock_client:
mock_client().client.net.key.public_key = mock.Mock(side_effect=self._public_key_mock)
mock_client().external_account_required.side_effect = self._true_mock
with mock.patch("certbot.eff.handle_subscription"):
with mock.patch("certbot._internal.eff.handle_subscription"):
with mock.patch("certbot._internal.client.messages.ExternalAccountBinding.from_data"):
self.config.eab_kid = None
self.config.eab_hmac_key = None
@@ -212,7 +212,7 @@ class RegisterTest(test_util.ConfigTestCase):
side_effect=self._new_acct_dir_mock
)
mock_client().external_account_required.side_effect = self._false_mock
with mock.patch("certbot.eff.handle_subscription") as mock_handle:
with mock.patch("certbot._internal.eff.handle_subscription") as mock_handle:
mock_client().new_account_and_tos.side_effect = [mx_err, mock.MagicMock()]
self.assertRaises(messages.Error, self._call)
self.assertFalse(mock_handle.called)

View File

@@ -1,4 +1,4 @@
"""Tests for certbot.eff."""
"""Tests for certbot._internal.eff."""
import unittest
import mock
@@ -9,7 +9,7 @@ import certbot.tests.util as test_util
class HandleSubscriptionTest(test_util.ConfigTestCase):
"""Tests for certbot.eff.handle_subscription."""
"""Tests for certbot._internal.eff.handle_subscription."""
def setUp(self):
super(HandleSubscriptionTest, self).setUp()
self.email = 'certbot@example.org'
@@ -17,11 +17,11 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
self.config.eff_email = None
def _call(self):
from certbot.eff import handle_subscription
from certbot._internal.eff import handle_subscription
return handle_subscription(self.config)
@test_util.patch_get_utility()
@mock.patch('certbot.eff.subscribe')
@mock.patch('certbot._internal.eff.subscribe')
def test_failure(self, mock_subscribe, mock_get_utility):
self.config.email = None
self.config.eff_email = True
@@ -32,7 +32,7 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
expected_part = "because you didn't provide an e-mail address"
self.assertTrue(expected_part in actual)
@mock.patch('certbot.eff.subscribe')
@mock.patch('certbot._internal.eff.subscribe')
def test_no_subscribe_with_no_prompt(self, mock_subscribe):
self.config.eff_email = False
with test_util.patch_get_utility() as mock_get_utility:
@@ -41,7 +41,7 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
self._assert_no_get_utility_calls(mock_get_utility)
@test_util.patch_get_utility()
@mock.patch('certbot.eff.subscribe')
@mock.patch('certbot._internal.eff.subscribe')
def test_subscribe_with_no_prompt(self, mock_subscribe, mock_get_utility):
self.config.eff_email = True
self._call()
@@ -53,7 +53,7 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
self.assertFalse(mock_get_utility().add_message.called)
@test_util.patch_get_utility()
@mock.patch('certbot.eff.subscribe')
@mock.patch('certbot._internal.eff.subscribe')
def test_subscribe_with_prompt(self, mock_subscribe, mock_get_utility):
mock_get_utility().yesno.return_value = True
self._call()
@@ -66,7 +66,7 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
self.assertEqual(mock_subscribe.call_args[0][0], self.email)
@test_util.patch_get_utility()
@mock.patch('certbot.eff.subscribe')
@mock.patch('certbot._internal.eff.subscribe')
def test_no_subscribe_with_prompt(self, mock_subscribe, mock_get_utility):
mock_get_utility().yesno.return_value = False
self._call()
@@ -84,18 +84,18 @@ class HandleSubscriptionTest(test_util.ConfigTestCase):
class SubscribeTest(unittest.TestCase):
"""Tests for certbot.eff.subscribe."""
"""Tests for certbot._internal.eff.subscribe."""
def setUp(self):
self.email = 'certbot@example.org'
self.json = {'status': True}
self.response = mock.Mock(ok=True)
self.response.json.return_value = self.json
@mock.patch('certbot.eff.requests.post')
@mock.patch('certbot._internal.eff.requests.post')
def _call(self, mock_post):
mock_post.return_value = self.response
from certbot.eff import subscribe
from certbot._internal.eff import subscribe
subscribe(self.email)
self._check_post_call(mock_post)

View File

@@ -1432,7 +1432,7 @@ class MainTest(test_util.ConfigTestCase): # pylint: disable=too-many-public-met
def test_update_account_with_email(self, mock_utility, mock_email):
email = "user@example.com"
mock_email.return_value = email
with mock.patch('certbot.eff.handle_subscription') as mock_handle:
with mock.patch('certbot._internal.eff.handle_subscription') as mock_handle:
with mock.patch('certbot._internal.main._determine_account') as mocked_det:
with mock.patch('certbot._internal.main.account') as mocked_account:
with mock.patch('certbot._internal.main.client') as mocked_client:
@@ -1464,7 +1464,7 @@ class MainTest(test_util.ConfigTestCase): # pylint: disable=too-many-public-met
def test_update_registration_with_email_deprecated(self, mock_utility, mock_email):
email = "user@example.com"
mock_email.return_value = email
with mock.patch('certbot.eff.handle_subscription') as mock_handle:
with mock.patch('certbot._internal.eff.handle_subscription') as mock_handle:
with mock.patch('certbot._internal.main._determine_account') as mocked_det:
with mock.patch('certbot._internal.main.account') as mocked_account:
with mock.patch('certbot._internal.main.client') as mocked_client:

View File

@@ -1,5 +0,0 @@
:mod:`certbot.eff`
----------------------
.. automodule:: certbot.eff
:members: