-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from alphagov/538-set-sensible-timeout-on-mai…
…lchimp-client 538 set sensible timeout on mailchimp client
- Loading branch information
Showing
3 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
from .flask_init import init_app, init_manager | ||
|
||
|
||
__version__ = '45.1.0' | ||
__version__ = '45.1.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the Digital Marketplace MailChimp integration.""" | ||
import logging | ||
import types | ||
from json.decoder import JSONDecodeError | ||
|
||
import mock | ||
import pytest | ||
import types | ||
|
||
from json.decoder import JSONDecodeError | ||
from requests import RequestException | ||
from requests.exceptions import HTTPError | ||
from requests.exceptions import HTTPError, ConnectTimeout | ||
|
||
from dmutils.email.dm_mailchimp import DMMailChimpClient | ||
|
||
from helpers import assert_external_service_log_entry, PatchExternalServiceLogConditionMixin | ||
|
||
|
||
|
@@ -262,6 +262,22 @@ def test_get_email_addresses_from_list_generates_emails(self): | |
mock.call('list_id', count=100, offset=100), | ||
] | ||
|
||
@mock.patch('dmutils.email.dm_mailchimp.MailChimp', autospec=True) | ||
def test_timeout_default_is_passed_to_client(self, mailchimp_client): | ||
DMMailChimpClient('username', DUMMY_MAILCHIMP_API_KEY, logging.getLogger('mailchimp')) | ||
args, kwargs = mailchimp_client.call_args | ||
|
||
assert kwargs['timeout'] == 25 | ||
|
||
def test_timeout_exception_is_not_propagated_for_create_or_update(self): | ||
dm_mailchimp_client = DMMailChimpClient('username', DUMMY_MAILCHIMP_API_KEY, logging.getLogger('mailchimp')) | ||
with mock.patch.object( | ||
dm_mailchimp_client._client.lists.members, 'create_or_update', autospec=True) as create_or_update: | ||
create_or_update.side_effect = ConnectTimeout() | ||
|
||
assert dm_mailchimp_client.subscribe_new_email_to_list('a_list_id', '[email protected]') is False | ||
assert create_or_update.called is True | ||
|
||
def test_default_timeout_retry_performs_no_retries(self): | ||
dm_mailchimp_client = DMMailChimpClient('username', DUMMY_MAILCHIMP_API_KEY, logging.getLogger('mailchimp')) | ||
with mock.patch.object(dm_mailchimp_client._client.lists.members, 'all', autospec=True) as all_members: | ||
|