File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ def __init__(self, **opts):
14
14
"""
15
15
self .path = opts .get ('path' , os .path .abspath (os .path .dirname (__file__ )))
16
16
self ._apikey = opts .get ('apikey' , os .environ .get ('SENDGRID_API_KEY' ))
17
+ # Support v2 api_key naming
18
+ self ._apikey = opts .get ('api_key' , os .environ .get ('SENDGRID_API_KEY' ))
19
+ self ._api_key = self ._apikey
17
20
self .useragent = 'sendgrid/{0};python' .format (__version__ )
18
21
self .host = opts .get ('host' , 'https://api.sendgrid.com' )
19
22
self .version = __version__
@@ -35,3 +38,11 @@ def apikey(self):
35
38
@apikey .setter
36
39
def apikey (self , value ):
37
40
self ._apikey = value
41
+
42
+ @property
43
+ def api_key (self ):
44
+ return self ._apikey
45
+
46
+ @api_key .setter
47
+ def api_key (self , value ):
48
+ self ._apikey = value
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class UnitTests(unittest.TestCase):
18
18
def setUpClass (cls ):
19
19
cls .host = host
20
20
cls .path = '{0}{1}' .format (os .path .abspath (os .path .dirname (__file__ )), '/..' )
21
- cls .sg = sendgrid .SendGridAPIClient (host = host , path = cls .path )
21
+ cls .sg = sendgrid .SendGridAPIClient (host = host , path = cls .path , api_key = os . environ . get ( 'SENDGRID_API_KEY' ) )
22
22
if os .path .isfile ('/usr/local/bin/prism' ) == False :
23
23
if sys .platform != 'win32' :
24
24
try :
@@ -38,6 +38,8 @@ def setUpClass(cls):
38
38
39
39
def test_apikey_init (self ):
40
40
self .assertEqual (self .sg .apikey , os .environ .get ('SENDGRID_API_KEY' ))
41
+ # Support the previous naming convention for API keys
42
+ self .assertEqual (self .sg .api_key , self .sg .apikey )
41
43
42
44
def test_useragent (self ):
43
45
useragent = '{0}{1}{2}' .format ('sendgrid/' , __version__ , ';python' )
You can’t perform that action at this time.
0 commit comments