File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 1- .PHONY : analysis all build clean docs docs-install docs-open install release release-test test venv
1+ .PHONY : analysis all build clean docs docs-install docs-open install release release-test test venv
22
33all : clean venv install
44
Original file line number Diff line number Diff line change 11import base64
22import copy
33import json
4+ import warnings
45from email .utils import parseaddr
56
67from .base import Resource
@@ -270,15 +271,21 @@ def get(self, transmission_id):
270271 results = self ._fetch_get (transmission_id )
271272 return results ['transmission' ]
272273
273- def list (self ):
274+ def list (self , ** kwargs ):
274275 """
275276 Get a list of your transmissions
276277
278+ :param campaign_id: ID of the campaign used by the transmissions
279+ :param template_id: ID of the template used by the transmissions
280+
277281 :returns: list of transmissions
278282 :raises: :exc:`SparkPostAPIException` if API call fails
279283 """
280- results = self .request ('GET' , self .uri )
281- return results
284+ warn_msg = 'This endpoint is deprecated. For details, '
285+ 'check https://sparkpo.st/5qcj4.'
286+
287+ warnings .warn (warn_msg , DeprecationWarning )
288+ return self .request ('GET' , self .uri , params = kwargs )
282289
283290 def delete (self , transmission_id ):
284291 """
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ pytest==2.8.7
33pytest-cov==1.8.1
44requests==2.5.1
55responses==0.3.0
6+ mock==2.0.0
Original file line number Diff line number Diff line change 22import json
33import os
44import tempfile
5+ import warnings
56
67import pytest
78import responses
89import six
10+ from mock import patch
911
1012from sparkpost import SparkPost
1113from sparkpost import Transmissions
@@ -303,7 +305,8 @@ def test_fail_get():
303305
304306
305307@responses .activate
306- def test_success_list ():
308+ @patch .object (warnings , 'warn' )
309+ def test_success_list (mock_warn ):
307310 responses .add (
308311 responses .GET ,
309312 'https://api.sparkpost.com/api/v1/transmissions' ,
@@ -313,6 +316,23 @@ def test_success_list():
313316 )
314317 sp = SparkPost ('fake-key' )
315318 response = sp .transmission .list ()
319+ assert mock_warn .called
320+ assert response == []
321+
322+
323+ @responses .activate
324+ def test_success_list_with_params ():
325+ responses .add (
326+ responses .GET ,
327+ 'https://api.sparkpost.com/api/v1/transmissions?template_id=abcd' ,
328+ status = 200 ,
329+ content_type = 'application/json' ,
330+ body = '{"results": []}' ,
331+ match_querystring = True
332+
333+ )
334+ sp = SparkPost ('fake-key' )
335+ response = sp .transmission .list (template_id = 'abcd' )
316336 assert response == []
317337
318338
You can’t perform that action at this time.
0 commit comments