6
6
from mox import Mox
7
7
8
8
import bitly
9
- from bitly import urllib2
9
+ from bitly import httplib2
10
10
11
11
def test_urls_shortening_scenario_for_plain_urls ():
12
12
api = bitly .Api (login = 'jcfigueiredo' , apikey = 'R_1cf5dc0fa14c2df34261fb620bd256aa' )
@@ -108,8 +108,8 @@ def verifying_that_a_custom_exception_is_raised_on_timeout(api):
108
108
109
109
bitly_shortening_url = 'http://api.bit.ly/shorten?login=jcfigueiredo&version=2.0.1&apiKey=R_1cf5dc0fa14c2df34261fb620bd256aa&format=json&longUrl=http%3A%2F%2Fwww.matandorobosgigantes.com'
110
110
111
- mox .StubOutWithMock (urllib2 , "urlopen " )
112
- urllib2 . urlopen ( url = bitly_shortening_url ).AndRaise (URLError ('urlopen error timed out' ))
111
+ mox .StubOutWithMock (httplib2 . Http , "request " )
112
+ httplib2 . Http . request ( bitly_shortening_url ).AndRaise (URLError ('urlopen error timed out' ))
113
113
114
114
url_to_be_shortened = 'http://www.matandorobosgigantes.com'
115
115
@@ -125,8 +125,8 @@ def verifying_that_urlerror_exceptions_are_reraised_but_timeout_exceptions(api):
125
125
126
126
bitly_shortening_url = 'http://api.bit.ly/shorten?login=jcfigueiredo&version=2.0.1&apiKey=R_1cf5dc0fa14c2df34261fb620bd256aa&format=json&longUrl=http%3A%2F%2Fwww.matandorobosgigantes.com'
127
127
128
- mox .StubOutWithMock (urllib2 , "urlopen " )
129
- urllib2 . urlopen ( url = bitly_shortening_url ).AndRaise (URLError ('something different from timeout' ))
128
+ mox .StubOutWithMock (httplib2 . Http , "request " )
129
+ httplib2 . Http . request ( bitly_shortening_url ).AndRaise (URLError ('something different from timeout' ))
130
130
131
131
url_to_be_shortened = 'http://www.matandorobosgigantes.com'
132
132
@@ -142,8 +142,8 @@ def verifying_that_any_other_exceptions_are_reraised_but_timeout_exceptions(api)
142
142
143
143
bitly_shortening_url = 'http://api.bit.ly/shorten?login=jcfigueiredo&version=2.0.1&apiKey=R_1cf5dc0fa14c2df34261fb620bd256aa&format=json&longUrl=http%3A%2F%2Fwww.matandorobosgigantes.com'
144
144
145
- mox .StubOutWithMock (urllib2 , "urlopen " )
146
- urllib2 . urlopen ( url = bitly_shortening_url ).AndRaise (ValueError ('something different' ))
145
+ mox .StubOutWithMock (httplib2 . Http , "request " )
146
+ httplib2 . Http . request ( bitly_shortening_url ).AndRaise (ValueError ('something different' ))
147
147
148
148
url_to_be_shortened = 'http://www.matandorobosgigantes.com'
149
149
0 commit comments