mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 18:04:31 +02:00
Update unit tests for determine_authenticator
The last commit refactored determine_authenticator to take a mapping of authenticator names to authenticators instead of a list of authenticators. This commit updates the existing unit tests to work with this refactor.
This commit is contained in:
+1
-1
@@ -9,4 +9,4 @@ m3
|
|||||||
*~
|
*~
|
||||||
.vagrant
|
.vagrant
|
||||||
*.swp
|
*.swp
|
||||||
\#*#
|
\#*#
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""letsencrypt.client.client.py tests."""
|
"""letsencrypt.client.client.py tests."""
|
||||||
|
from collections import namedtuple
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
@@ -20,12 +21,18 @@ class DetermineAuthenticatorTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.mock_config = mock.Mock()
|
self.mock_config = mock.Mock()
|
||||||
|
|
||||||
self.all_auths = [self.mock_apache, self.mock_stand]
|
self.all_auths = {
|
||||||
|
'apache': self.mock_apache,
|
||||||
|
'standalone': self.mock_stand
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _call(cls, all_auths):
|
def _call(cls, all_auths):
|
||||||
from letsencrypt.client.client import determine_authenticator
|
from letsencrypt.client.client import determine_authenticator
|
||||||
return determine_authenticator(all_auths)
|
# TODO: add tests for setting the authenticator via the command line
|
||||||
|
mock_config = namedtuple("Config", ['authenticator'])
|
||||||
|
return determine_authenticator(all_auths,
|
||||||
|
mock_config(authenticator=None))
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.client.display_ops.choose_authenticator")
|
@mock.patch("letsencrypt.client.client.display_ops.choose_authenticator")
|
||||||
def test_accept_two(self, mock_choose):
|
def test_accept_two(self, mock_choose):
|
||||||
@@ -35,7 +42,8 @@ class DetermineAuthenticatorTest(unittest.TestCase):
|
|||||||
def test_accept_one(self):
|
def test_accept_one(self):
|
||||||
self.mock_apache.prepare.return_value = self.mock_apache
|
self.mock_apache.prepare.return_value = self.mock_apache
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self._call(self.all_auths[:1]), self.mock_apache)
|
self._call(dict(apache=self.all_auths['apache'])),
|
||||||
|
self.mock_apache)
|
||||||
|
|
||||||
def test_no_installation_one(self):
|
def test_no_installation_one(self):
|
||||||
self.mock_apache.prepare.side_effect = (
|
self.mock_apache.prepare.side_effect = (
|
||||||
|
|||||||
Reference in New Issue
Block a user