diff --git a/Makefile b/Makefile index ac4084e..2725b63 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv +.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv all: clean venv install diff --git a/sparkpost/transmissions.py b/sparkpost/transmissions.py index 3586e2f..997f822 100644 --- a/sparkpost/transmissions.py +++ b/sparkpost/transmissions.py @@ -1,6 +1,7 @@ import base64 import copy import json +import warnings from email.utils import parseaddr from .base import Resource @@ -265,15 +266,21 @@ def get(self, transmission_id): results = self._fetch_get(transmission_id) return results['transmission'] - def list(self): + def list(self, **kwargs): """ Get a list of your transmissions + :param campaign_id: ID of the campaign used by the transmissions + :param template_id: ID of the template used by the transmissions + :returns: list of transmissions :raises: :exc:`SparkPostAPIException` if API call fails """ - results = self.request('GET', self.uri) - return results + warn_msg = 'This endpoint is deprecated. For details, ' + 'check https://sparkpo.st/5qcj4.' + + warnings.warn(warn_msg, DeprecationWarning) + return self.request('GET', self.uri, params=kwargs) def delete(self, transmission_id): """ diff --git a/test-requirements.txt b/test-requirements.txt index 98fd527..6516877 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,3 +3,4 @@ pytest==2.8.7 pytest-cov==1.8.1 requests==2.5.1 responses==0.3.0 +mock==2.0.0 diff --git a/test/test_transmissions.py b/test/test_transmissions.py index 9847fb2..172dcb7 100644 --- a/test/test_transmissions.py +++ b/test/test_transmissions.py @@ -2,10 +2,12 @@ import json import os import tempfile +import warnings import pytest import responses import six +from mock import patch from sparkpost import SparkPost from sparkpost import Transmissions @@ -297,7 +299,8 @@ def test_fail_get(): @responses.activate -def test_success_list(): +@patch.object(warnings, 'warn') +def test_success_list(mock_warn): responses.add( responses.GET, 'https://api.sparkpost.com/api/v1/transmissions', @@ -307,6 +310,23 @@ def test_success_list(): ) sp = SparkPost('fake-key') response = sp.transmission.list() + assert mock_warn.called + assert response == [] + + +@responses.activate +def test_success_list_with_params(): + responses.add( + responses.GET, + 'https://api.sparkpost.com/api/v1/transmissions?template_id=abcd', + status=200, + content_type='application/json', + body='{"results": []}', + match_querystring=True + + ) + sp = SparkPost('fake-key') + response = sp.transmission.list(template_id='abcd') assert response == []