def test_send_proxied(self, mock_requests): mock_response = mock.MagicMock(requests.Response) mock_requests.put.return_value = mock_response periodic.send_heartbeat('endpoint', '{"fake": "json"}') mock_requests.put.assert_called_once_with(mock.ANY, json=mock.ANY, timeout=mock.ANY) mock_requests.reset_mock() periodic.send_heartbeat('endpoint', '{"fake": "json"}', proxies={'https': 'dummy'}) mock_requests.put.assert_called_once_with(mock.ANY, json=mock.ANY, timeout=mock.ANY, proxies={'https': 'dummy'})
def test_send_unhandled(self, mock_logging): endpoint = 'https://heartbeat_unhandled.hg.com/beat' with httmock.HTTMock(heartbeat_unhandled_mock): periodic.send_heartbeat(endpoint, '{"fake": "json"}') mock_logging.error.assert_called()