newsletters: fix logging in case of connection error (#23825)
This commit is contained in:
parent
70c5da0d23
commit
bfc98e907a
|
@ -120,8 +120,8 @@ class NewslettersCell(CellBase):
|
|||
if 'uuid' not in kwargs:
|
||||
raise SubscriptionsSaveError
|
||||
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
|
||||
endpoint = self.url + 'subscriptions/'
|
||||
try:
|
||||
endpoint = self.url + 'subscriptions/'
|
||||
response = requests.post(endpoint, remote_service='auto', data=json.dumps(subscriptions),
|
||||
user=user, federation_key='email', params=kwargs, headers=headers)
|
||||
if not response.json()['data']:
|
||||
|
@ -132,7 +132,7 @@ class NewslettersCell(CellBase):
|
|||
raise SubscriptionsSaveError
|
||||
except RequestException, e:
|
||||
logger.error(u'set subscriptions on %s failed with exception: %s',
|
||||
url, e)
|
||||
endpoint, e)
|
||||
raise SubscriptionsSaveError
|
||||
|
||||
def render(self, context):
|
||||
|
|
|
@ -170,7 +170,7 @@ def test_get_subscriptions_signature_check(mock_get, cell, user):
|
|||
def mocked_requests_connection_error(*args, **kwargs):
|
||||
raise requests.ConnectionError()
|
||||
|
||||
@mock.patch('combo.apps.newsletters.models.requests.get',
|
||||
@mock.patch('combo.apps.newsletters.models.requests.post',
|
||||
side_effect=mocked_requests_connection_error)
|
||||
def test_failed_set_subscriptions(mock_post, cell, user):
|
||||
restrictions = ('sms', 'mail')
|
||||
|
@ -180,7 +180,7 @@ def test_failed_set_subscriptions(mock_post, cell, user):
|
|||
{'id': '8', 'transports': [{'id': 'sms', 'text': 'sms'},
|
||||
{'id': 'mail', 'text': 'mail'}]}]
|
||||
with pytest.raises(SubscriptionsSaveError):
|
||||
cell.set_subscriptions(subscriptions, user)
|
||||
cell.set_subscriptions(subscriptions, user, uuid='useruuid')
|
||||
|
||||
@mock.patch('combo.apps.newsletters.models.requests.post')
|
||||
def test_set_subscriptions_with_no_uuid(mocked_post, cell, user):
|
||||
|
|
Loading…
Reference in New Issue