File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change
1
+ from nose .tools import assert_equal
2
+
3
+ from twilio .rest import find_credentials
4
+
5
+ def test_creds_not_found ():
6
+ """ I shouldn't find credentials if they are not there """
7
+ assert_equal (find_credentials ({'foo' : 'bar' }), (None , None ))
8
+
9
+ def test_find_creds ():
10
+ """ I should find the credentials if they are there """
11
+ env = {
12
+ 'TWILIO_ACCOUNT_SID' : 'AC123' ,
13
+ 'foo' : 'bar' ,
14
+ 'TWILIO_AUTH_TOKEN' : '456' ,
15
+ }
16
+ assert_equal (find_credentials (env ), ('AC123' , '456' ))
17
+
Original file line number Diff line number Diff line change 28
28
from twilio .rest .resources import Usage
29
29
30
30
31
- def find_credentials ():
31
+ def find_credentials (environ = None ):
32
32
"""
33
33
Look in the current environment for Twilio credentials
34
+
35
+ :param environ: the environment to check
34
36
"""
37
+ environment = environ or os .environ
35
38
try :
36
- account = os . environ ["TWILIO_ACCOUNT_SID" ]
37
- token = os . environ ["TWILIO_AUTH_TOKEN" ]
39
+ account = environment ["TWILIO_ACCOUNT_SID" ]
40
+ token = environment ["TWILIO_AUTH_TOKEN" ]
38
41
return account , token
39
42
except KeyError :
40
43
return None , None
You can’t perform that action at this time.
0 commit comments