~nataliabidart/ubuntu-sso-client/displayname-stable

« back to all changes in this revision

Viewing changes to ubuntu_sso/tests/test_main.py

  • Committer: Tarmac
  • Author(s): natalia.bidart at canonical
  • Date: 2010-10-18 21:16:46 UTC
  • mfrom: (634.1.1 handle-ping-error)
  • Revision ID: tarmac-20101018211646-82syq2lupae2qdge
* Credentials are removed if the pinging to the server fails or any other exception occurs (LP: #660516).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1367
1367
        self.assertEqual(self.calls[0][0], 'CredentialsError')
1368
1368
        self.assertEqual(self.calls[0][1][0], APP_NAME)
1369
1369
 
 
1370
    def test_credentials_are_not_stored_if_ping_failed(self):
 
1371
        """Credentials are not stored if the ping fails."""
 
1372
 
 
1373
        def fail(*args, **kwargs):
 
1374
            """Raise an exception."""
 
1375
            self.args = AssertionError((args, kwargs))
 
1376
            # pylint: disable=E0702
 
1377
            raise self.args
 
1378
 
 
1379
        self.patch(self.client, '_ping_url', fail)
 
1380
        self._patch('clear_token')
 
1381
 
 
1382
        self.client._login_success_cb(None, APP_NAME, EMAIL)
 
1383
 
 
1384
        self.assertEqual(len(self.calls), 1)
 
1385
        self.assertEqual(self.calls[0][0], 'clear_token')
 
1386
        self.assertEqual(self.calls[0][1][0], APP_NAME)
 
1387
 
1370
1388
 
1371
1389
class EnvironOverridesTestCase(TestCase):
1372
1390
    """Some URLs can be set from the environment for testing/QA purposes."""