Skip to content

Commit

Permalink
Merge 7dff42d into 8808080
Browse files Browse the repository at this point in the history
  • Loading branch information
rajumsys committed Mar 6, 2017
2 parents 8808080 + 7dff42d commit 0797e12
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
10 changes: 7 additions & 3 deletions sparkpost/transmissions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import copy
import json
import warnings
from email.utils import parseaddr

from .base import Resource
Expand Down Expand Up @@ -265,15 +266,18 @@ 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
warnings.warn('deprecated', DeprecationWarning)
return self.request('GET', self.uri, params=kwargs)

def delete(self, transmission_id):
"""
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 21 additions & 1 deletion test/test_transmissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import os
import tempfile
import warnings
from mock import patch

import pytest
import responses
Expand Down Expand Up @@ -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',
Expand All @@ -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 == []


Expand Down

0 comments on commit 0797e12

Please sign in to comment.