~ubuntuone-control-tower/ubuntu-sso-client/stable-1-2

« back to all changes in this revision

Viewing changes to ubuntu_sso/tests/test_credentials.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2012-06-22 19:51:52 UTC
  • mfrom: (689.1.2 use-pycurl-1-2)
  • Revision ID: tarmac-20120622195152-29b4mbt5fpbwlq9h
- Use pycurl instead of httplib (LP: #882055).

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
        self.patch(credentials.Keyring, 'get_credentials',
281
281
                   lambda kr, app: defer.succeed(TOKEN))
282
282
        error = 'Bla'
283
 
        self.patch(credentials.urllib2, 'urlopen',
 
283
        self.patch(credentials.curllib, 'urlopen',
284
284
                   lambda *a, **kw: self.fail(error))
285
285
        self._cred_cleared = False
286
286
        self.patch(self.obj, 'clear_credentials',
359
359
                                         code=200)
360
360
            return response
361
361
 
362
 
        self.patch(credentials.urllib2, 'urlopen', faked_urlopen)
 
362
        self.patch(credentials.curllib, 'urlopen', faked_urlopen)
363
363
        self.patch(credentials.utils.timestamp_checker, "get_faithful_time",
364
364
                   time.time)
365
365
 
366
366
    @inlineCallbacks
367
367
    def test_ping_url_if_url_is_none(self):
368
368
        """self.ping_url is opened."""
369
 
        self.patch(credentials.urllib2, 'urlopen', self.fail)
 
369
        self.patch(credentials.curllib, 'urlopen', self.fail)
370
370
        self.obj.ping_url = None
371
371
        yield self.obj._ping_url(app_name=APP_NAME, email=EMAIL,
372
372
                                 credentials=TOKEN)
378
378
        yield self.obj._ping_url(app_name=APP_NAME, email=EMAIL,
379
379
                                 credentials=TOKEN)
380
380
 
381
 
        self.assertIsInstance(self._request, credentials.urllib2.Request)
 
381
        self.assertIsInstance(self._request, credentials.curllib.Request)
382
382
        self.assertEqual(self._request.get_full_url(),
383
383
                         self.obj.ping_url + EMAIL)
384
384
 
402
402
    def test_ping_url_error(self):
403
403
        """Exception is handled if ping fails."""
404
404
        error = 'Blu'
405
 
        self.patch(credentials.urllib2, 'urlopen', lambda r: self.fail(error))
 
405
        self.patch(credentials.curllib, 'urlopen', lambda r: self.fail(error))
406
406
 
407
407
        yield self.obj._ping_url(APP_NAME, EMAIL, TOKEN)
408
408