File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ Patches and suggestions
19
19
- `@gnarvaja <https://github.com/gnarvaja >`_
20
20
- `@pegler <https://github.com/pegler >`_
21
21
- `@puttu <https://github.com/puttu >`_
22
+ - Dmitry Tyukin `@deems <https://github.com/deems >`_
22
23
- ADD YOURSELF HERE (and link to your github page)
Original file line number Diff line number Diff line change @@ -259,3 +259,17 @@ def list(self):
259
259
"""
260
260
results = self .request ('GET' , self .uri )
261
261
return results
262
+
263
+ def delete (self , transmission_id ):
264
+ """
265
+ Delete a transmission by ID
266
+
267
+ :param str transmission_id: ID of the transmission you want to delete
268
+
269
+ :returns: {} if transmission is deleted
270
+ :raises: :exc:`SparkPostAPIException` if transmission is not found
271
+ or Canceled
272
+ """
273
+ uri = "%s/%s" % (self .uri , transmission_id )
274
+ results = self .request ('DELETE' , uri )
275
+ return results
Original file line number Diff line number Diff line change @@ -271,3 +271,34 @@ def test_success_list():
271
271
sp = SparkPost ('fake-key' )
272
272
response = sp .transmission .list ()
273
273
assert response == []
274
+
275
+
276
+ @responses .activate
277
+ def test_success_delete ():
278
+ responses .add (
279
+ responses .DELETE ,
280
+ 'https://api.sparkpost.com/api/v1/transmissions/foobar' ,
281
+ status = 200 ,
282
+ content_type = 'application/json' ,
283
+ body = '{}'
284
+ )
285
+ sp = SparkPost ('fake-key' )
286
+ results = sp .transmission .delete ('foobar' )
287
+ assert results == {}
288
+
289
+
290
+ @responses .activate
291
+ def test_fail_delete ():
292
+ responses .add (
293
+ responses .DELETE ,
294
+ 'https://api.sparkpost.com/api/v1/transmissions/foobar' ,
295
+ status = 404 ,
296
+ content_type = 'application/json' ,
297
+ body = """
298
+ {"errors": [{"message": "resource not found",
299
+ "description": "Resource not found:transmission id foobar""}]}
300
+ """
301
+ )
302
+ with pytest .raises (SparkPostAPIException ):
303
+ sp = SparkPost ('fake-key' )
304
+ sp .transmission .delete ('foobar' )
You can’t perform that action at this time.
0 commit comments