1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-21 19:01:07 +03: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:
Garrett Robinson
2015-04-09 15:32:20 -07:00
parent 5d2abc30f0
commit 79f5ebe734
2 changed files with 12 additions and 4 deletions

2
.gitignore vendored
View File

@@ -9,4 +9,4 @@ m3
*~
.vagrant
*.swp
\#*#
\#*#

View File

@@ -1,4 +1,5 @@
"""letsencrypt.client.client.py tests."""
from collections import namedtuple
import unittest
import mock
@@ -20,12 +21,18 @@ class DetermineAuthenticatorTest(unittest.TestCase):
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
def _call(cls, all_auths):
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")
def test_accept_two(self, mock_choose):
@@ -35,7 +42,8 @@ class DetermineAuthenticatorTest(unittest.TestCase):
def test_accept_one(self):
self.mock_apache.prepare.return_value = self.mock_apache
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):
self.mock_apache.prepare.side_effect = (