Skip to content

Commit a781555

Browse files
committed
add deprecation warning, add warning test
1 parent 693d568 commit a781555

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sparkpost/transmissions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import copy
33
import json
4+
import warnings
45
from email.utils import parseaddr
56

67
from .base import Resource
@@ -275,6 +276,7 @@ def list(self, **kwargs):
275276
:returns: list of transmissions
276277
:raises: :exc:`SparkPostAPIException` if API call fails
277278
"""
279+
warnings.warn('deprecated', DeprecationWarning)
278280
return self.request('GET', self.uri, params=kwargs)
279281

280282
def delete(self, transmission_id):

test/test_transmissions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import tempfile
5+
import warnings
56

67
import pytest
78
import responses
@@ -306,8 +307,12 @@ def test_success_list():
306307
body='{"results": []}'
307308
)
308309
sp = SparkPost('fake-key')
309-
response = sp.transmission.list()
310-
assert response == []
310+
with warnings.catch_warnings(record=True) as warns:
311+
warnings.simplefilter("always")
312+
response = sp.transmission.list()
313+
assert response == []
314+
assert len(warns) == 1
315+
assert "deprecated" in str(warns[-1].message)
311316

312317

313318
@responses.activate

0 commit comments

Comments
 (0)