@@ -40,7 +40,7 @@ def _callFUT(self, *args, **kwargs):
40
40
return generate_signed_url (* args , ** kwargs )
41
41
42
42
def _generate_helper (self , response_type = None , response_disposition = None ,
43
- generation = None , credentials = None ):
43
+ generation = None ):
44
44
import base64
45
45
from six .moves .urllib .parse import parse_qs
46
46
from six .moves .urllib .parse import urlsplit
@@ -50,7 +50,7 @@ def _generate_helper(self, response_type=None, response_disposition=None,
50
50
ENDPOINT = 'http://api.example.com'
51
51
RESOURCE = '/name/path'
52
52
SIGNED = base64 .b64encode (b'DEADBEEF' )
53
- CREDENTIALS = credentials or _Credentials ()
53
+ CREDENTIALS = _Credentials ()
54
54
55
55
def _get_signed_query_params (* args ):
56
56
credentials , expiration = args [:2 ]
@@ -90,19 +90,27 @@ def _get_signed_query_params(*args):
90
90
self .assertEqual (frag , '' )
91
91
92
92
def test_w_expiration_int (self ):
93
- self ._generate_helper (credentials = _Credentials ())
94
-
95
- def test_w_google_credentials (self ):
96
- self ._generate_helper (credentials = _GoogleCredentials ())
93
+ self ._generate_helper ()
97
94
98
95
def test_w_custom_fields (self ):
99
96
response_type = 'text/plain'
100
97
response_disposition = 'attachment; filename=blob.png'
101
98
generation = '123'
102
99
self ._generate_helper (response_type = response_type ,
103
100
response_disposition = response_disposition ,
104
- generation = generation ,
105
- credentials = _Credentials ())
101
+ generation = generation )
102
+
103
+
104
+ class Test_generate_signed_url_exception (unittest2 .TestCase ):
105
+ def test_with_google_credentials (self ):
106
+ import time
107
+ from gcloud .credentials import generate_signed_url
108
+ RESOURCE = '/name/path'
109
+
110
+ credentials = _GoogleCredentials ()
111
+ expiration = int (time .time () + 5 )
112
+ self .assertRaises (AttributeError , generate_signed_url , credentials ,
113
+ resource = RESOURCE , expiration = expiration )
106
114
107
115
108
116
class Test__get_signed_query_params (unittest2 .TestCase ):
@@ -114,8 +122,6 @@ def _callFUT(self, credentials, expiration, string_to_sign):
114
122
115
123
def test_it (self ):
116
124
import base64
117
- # from gcloud._testing import _Monkey
118
- # from gcloud import credentials as MUT
119
125
120
126
SIG_BYTES = b'DEADBEEF'
121
127
ACCOUNT_NAME = object ()
0 commit comments