1111from SoftLayer import transports
1212
1313
14- def get_creds ():
15- for key in 'SL_USERNAME SL_API_KEY' .split ():
16- if key not in os .environ :
17- raise testing .unittest .SkipTest (
18- 'SL_USERNAME and SL_API_KEY environmental variables not set' )
14+ class FunctionalTest (testing .TestCase ):
15+ def _get_creds (self ):
16+ for key in 'SL_USERNAME SL_API_KEY' .split ():
17+ if key not in os .environ :
18+ raise self .skipTest ('SL_USERNAME and SL_API_KEY environmental '
19+ 'variables not set' )
1920
20- return {
21- 'endpoint' : (os .environ .get ('SL_API_ENDPOINT' ) or
22- SoftLayer .API_PUBLIC_ENDPOINT ),
23- 'username' : os .environ ['SL_USERNAME' ],
24- 'api_key' : os .environ ['SL_API_KEY' ]
25- }
21+ return {
22+ 'endpoint' : (os .environ .get ('SL_API_ENDPOINT' ) or
23+ SoftLayer .API_PUBLIC_ENDPOINT ),
24+ 'username' : os .environ ['SL_USERNAME' ],
25+ 'api_key' : os .environ ['SL_API_KEY' ]
26+ }
2627
2728
28- class UnauthedUser (testing .TestCase ):
29+ class UnauthedUser (FunctionalTest ):
30+
2931 def test_failed_auth (self ):
3032 client = SoftLayer .Client (
3133 username = 'doesnotexist' , api_key = 'issurelywrong' , timeout = 20 )
@@ -52,9 +54,9 @@ def test_no_hostname(self):
5254 self .fail ('No Exception Raised' )
5355
5456
55- class AuthedUser (testing . TestCase ):
57+ class AuthedUser (FunctionalTest ):
5658 def test_service_does_not_exist (self ):
57- creds = get_creds ()
59+ creds = self . _get_creds ()
5860 client = SoftLayer .Client (
5961 username = creds ['username' ],
6062 api_key = creds ['api_key' ],
@@ -71,7 +73,7 @@ def test_service_does_not_exist(self):
7173 self .fail ('No Exception Raised' )
7274
7375 def test_get_users (self ):
74- creds = get_creds ()
76+ creds = self . _get_creds ()
7577 client = SoftLayer .Client (
7678 username = creds ['username' ],
7779 api_key = creds ['api_key' ],
@@ -86,7 +88,7 @@ def test_get_users(self):
8688 self .assertTrue (found )
8789
8890 def test_result_types (self ):
89- creds = get_creds ()
91+ creds = self . _get_creds ()
9092 client = SoftLayer .Client (
9193 username = creds ['username' ],
9294 api_key = creds ['api_key' ],
0 commit comments