[Python-modules-commits] [python-sparkpost] 01/04: Import python-sparkpost_1.3.3.orig.tar.gz

Scott Kitterman kitterman at moszumanska.debian.org
Tue Jan 17 06:36:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch master
in repository python-sparkpost.

commit bf265a52b7c012fb3d9b41f907e87ab3e7bd3a11
Author: Scott Kitterman <scott at kitterman.com>
Date:   Tue Jan 17 01:30:43 2017 -0500

    Import python-sparkpost_1.3.3.orig.tar.gz
---
 CHANGELOG.md               |  9 ++++++---
 docs/conf.py               |  2 +-
 setup.py                   |  2 +-
 sparkpost/__init__.py      |  2 +-
 sparkpost/exceptions.py    | 11 ++++-------
 test/test_base.py          | 14 ++++++++++++++
 test/test_transmissions.py |  2 +-
 7 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c57adf..d8ce2a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,12 +5,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 ## Unreleased
 - [Compare to latest release][unreleased]
 
+## [1.3.3] - 2017-01-13
+### Fixed
+- [#135](https://github.com/SparkPost/python-sparkpost/pull/135) Issue where exceptions were not returning properly for some underlying API errors
+
 ## [1.3.2] - 2016-11-14
 ### Fixed
 - [#129](https://github.com/SparkPost/python-sparkpost/pull/129) Reverted change for emojis in the body of a message, needs further investigation
 - [#129](https://github.com/SparkPost/python-sparkpost/pull/129) `substitution_data`, `metadata`, and `tags` are now supplied properly for cc/bcc recipients
 
-
 ## [1.3.1] - 2016-11-13
 ### Added
 - Instructions for use with Google Cloud
@@ -20,7 +23,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - [#118](https://github.com/SparkPost/python-sparkpost/pull/118) Fixed improper setting of header_to value when using cc and primary recipient has substitution data
 - [#119](https://github.com/SparkPost/python-sparkpost/pull/119) Added missing `sources` to suppression list key map
 
-
 ## [1.3.0] - 2016-10-01
 ### Added
 - [#121](https://github.com/SparkPost/python-sparkpost/pull/121) Added extended error code to `SparkPostAPIException` class
@@ -114,7 +116,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - Metrics class for getting a list of campaigns and domains
 - Docs on readthedocs.org
 
-[unreleased]: https://github.com/sparkpost/python-sparkpost/compare/v1.3.2...HEAD
+[unreleased]: https://github.com/sparkpost/python-sparkpost/compare/v1.3.3...HEAD
+[1.3.2]: https://github.com/sparkpost/python-sparkpost/compare/v1.3.2...v1.3.3
 [1.3.2]: https://github.com/sparkpost/python-sparkpost/compare/v1.3.1...v1.3.2
 [1.3.1]: https://github.com/sparkpost/python-sparkpost/compare/v1.3.0...v1.3.1
 [1.3.0]: https://github.com/sparkpost/python-sparkpost/compare/v1.2.0...v1.3.0
diff --git a/docs/conf.py b/docs/conf.py
index 1b925e7..692e53e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -60,7 +60,7 @@ copyright = u'2014-{year}, Message Systems'.format(year=now.year)
 # The short X.Y version.
 version = '1.3'
 # The full version, including alpha/beta/rc tags.
-release = '1.3.2'
+release = '1.3.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/setup.py b/setup.py
index a2486fd..25b598c 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ with open('README.rst', 'r', 'utf-8') as f:
 
 setup(
     name='sparkpost',
-    version='1.3.2',
+    version='1.3.3',
     author='SparkPost',
     author_email='developers at sparkpost.com',
     packages=find_packages(),
diff --git a/sparkpost/__init__.py b/sparkpost/__init__.py
index 320cd9a..96b40f7 100644
--- a/sparkpost/__init__.py
+++ b/sparkpost/__init__.py
@@ -9,7 +9,7 @@ from .templates import Templates
 from .transmissions import Transmissions
 
 
-__version__ = '1.3.2'
+__version__ = '1.3.3'
 
 
 class SparkPost(object):
diff --git a/sparkpost/exceptions.py b/sparkpost/exceptions.py
index 0fdb00d..3c2a9e9 100644
--- a/sparkpost/exceptions.py
+++ b/sparkpost/exceptions.py
@@ -5,17 +5,14 @@ class SparkPostException(Exception):
 class SparkPostAPIException(SparkPostException):
     "Handle 4xx and 5xx errors from the SparkPost API"
     def __init__(self, response, *args, **kwargs):
-        errors = None
         try:
             errors = response.json()['errors']
-            errors = [e['message'] +
-                      ' Code: ' + e.get('code', '') +
-                      ' Description: ' + e.get('description', '') +
-                      '\n'
+            error_template = "{message} Code: {code} Description: {desc} \n"
+            errors = [error_template.format(message=e.get('message', ''),
+                                            code=e.get('code', 'none'),
+                                            desc=e.get('description', 'none'))
                       for e in errors]
         except:
-            pass
-        if not errors:
             errors = [response.text or ""]
         self.status = response.status_code
         self.response = response
diff --git a/test/test_base.py b/test/test_base.py
index 0bd59cd..aff6b79 100644
--- a/test/test_base.py
+++ b/test/test_base.py
@@ -92,6 +92,20 @@ def test_fail_nojson_request():
         resource.request('GET', resource.uri)
 
 
+ at responses.activate
+def test_fail_no_errors():
+    responses.add(
+        responses.GET,
+        fake_uri,
+        status=500,
+        content_type='application/json',
+        body='no errors'
+    )
+    resource = create_resource()
+    with pytest.raises(SparkPostAPIException):
+        resource.request('GET', resource.uri)
+
+
 def test_fail_get():
     resource = create_resource()
     with pytest.raises(NotImplementedError):
diff --git a/test/test_transmissions.py b/test/test_transmissions.py
index c2d4e32..9847fb2 100644
--- a/test/test_transmissions.py
+++ b/test/test_transmissions.py
@@ -333,7 +333,7 @@ def test_fail_delete():
         content_type='application/json',
         body="""
         {"errors": [{"message": "resource not found",
-            "description": "Resource not found:transmission id foobar""}]}
+            "description": "Resource not found:transmission id foobar"}]}
         """
     )
     with pytest.raises(SparkPostAPIException):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-sparkpost.git



More information about the Python-modules-commits mailing list