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 2828from twilio .rest .resources import Usage
2929
3030
31- def find_credentials ():
31+ def find_credentials (environ = None ):
3232 """
3333 Look in the current environment for Twilio credentials
34+
35+ :param environ: the environment to check
3436 """
37+ environment = environ or os .environ
3538 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" ]
3841 return account , token
3942 except KeyError :
4043 return None , None
You can’t perform that action at this time.
0 commit comments