Skip to content

Commit

Permalink
1.16 compat: mock certbot._internal.main.display_util.notify (#15)
Browse files Browse the repository at this point in the history
* 1.16 compat: mock certbot._internal.main.display_util.notify
* backward compatibility for cerbot without notify in certbot.display.util
  • Loading branch information
reneluria authored Jun 24, 2021
1 parent ccfb0b6 commit 9338076
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion certbot_dns_infomaniak/dns_infomaniak_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from unittest import mock
import requests_mock

import sys
import io

from certbot.errors import PluginError
try:
import certbot.compat.os as os
Expand Down Expand Up @@ -39,9 +42,22 @@ def setUp(self):
self.auth = Authenticator(self.config, "infomaniak")

self.mock_client = mock.MagicMock(default_propagation_seconds=15)
# _get_ispconfig_client | pylint: disable=protected-access

self.auth._api_client = mock.MagicMock(return_value=self.mock_client)

try:
from certbot.display.util import notify # noqa: F401
notify_patch = mock.patch('certbot._internal.main.display_util.notify')
self.mock_notify = notify_patch.start()
self.addCleanup(notify_patch.stop)
self.old_stdout = sys.stdout
sys.stdout = io.StringIO()
except ImportError:
self.old_stdout = sys.stdout

def tearDown(self):
sys.stdout = self.old_stdout

def test_perform(self):
"""Tests the perform function to see if client method is called"""
self.auth.perform([self.achall])
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
certbot<1.16.0
certbot>=0.31.0
setuptools
requests
requests-mock
Expand Down

0 comments on commit 9338076

Please sign in to comment.