From 79f5ebe734d18ddbc70dfbd22de4ce76f995a20a Mon Sep 17 00:00:00 2001 From: Garrett Robinson Date: Thu, 9 Apr 2015 15:32:20 -0700 Subject: [PATCH] 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. --- .gitignore | 2 +- letsencrypt/client/tests/client_test.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf969454..e2ec0622c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ m3 *~ .vagrant *.swp -\#*# \ No newline at end of file +\#*# diff --git a/letsencrypt/client/tests/client_test.py b/letsencrypt/client/tests/client_test.py index 1c1a0d68a..2310dbe87 100644 --- a/letsencrypt/client/tests/client_test.py +++ b/letsencrypt/client/tests/client_test.py @@ -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 = (