From 22f406a4df17742ef96341e43f8ac776e533bf08 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 26 Jul 2016 09:32:33 -0700 Subject: [PATCH] Version Bump v3.1.9: Issue #197: api_key / apikey attribute logic incorrect --- CHANGELOG.md | 5 +++++ sendgrid/sendgrid.py | 2 +- sendgrid/version.py | 2 +- test/test_sendgrid.py | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f42a1ba..27d299729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log All notable changes to this project will be documented in this file. +## [3.1.9] - 2016-07-26 ## +### Fixed +- [Issue #197](https://github.com/sendgrid/sendgrid-python/issues/197): api_key / apikey attribute logic incorrect +- Thanks to [johguse](https://github.com/johguse) for reporting the bug + ## [3.1.8] - 2016-07-25 ## ### Added - [Troubleshooting](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md) section diff --git a/sendgrid/sendgrid.py b/sendgrid/sendgrid.py index efef3c9ae..43e4fbd93 100644 --- a/sendgrid/sendgrid.py +++ b/sendgrid/sendgrid.py @@ -15,7 +15,7 @@ def __init__(self, **opts): self.path = opts.get('path', os.path.abspath(os.path.dirname(__file__))) self._apikey = opts.get('apikey', os.environ.get('SENDGRID_API_KEY')) # Support v2 api_key naming - self._apikey = opts.get('api_key', os.environ.get('SENDGRID_API_KEY')) + self._apikey = opts.get('api_key', self._apikey) self._api_key = self._apikey self.useragent = 'sendgrid/{0};python'.format(__version__) self.host = opts.get('host', 'https://api.sendgrid.com') diff --git a/sendgrid/version.py b/sendgrid/version.py index f7e2328ab..029d78e79 100644 --- a/sendgrid/version.py +++ b/sendgrid/version.py @@ -1,2 +1,2 @@ -version_info = (3, 1, 8) +version_info = (3, 1, 9) __version__ = '.'.join(str(v) for v in version_info) diff --git a/test/test_sendgrid.py b/test/test_sendgrid.py index b96291b0f..dcf21ce49 100644 --- a/test/test_sendgrid.py +++ b/test/test_sendgrid.py @@ -40,6 +40,11 @@ def test_apikey_init(self): self.assertEqual(self.sg.apikey, os.environ.get('SENDGRID_API_KEY')) # Support the previous naming convention for API keys self.assertEqual(self.sg.api_key, self.sg.apikey) + my_sendgrid = sendgrid.SendGridAPIClient(apikey="THISISMYKEY") + tmp = os.environ.get('SENDGRID_API_KEY') + os.environ['SENDGRID_API_KEY'] = "" + self.assertEqual(my_sendgrid.apikey, "THISISMYKEY") + os.environ['SENDGRID_API_KEY'] = tmp def test_useragent(self): useragent = '{0}{1}{2}'.format('sendgrid/', __version__, ';python')