Add tests to contrib modules to restore coverage to 100%

This commit is contained in:
Pat Ferate
2016-07-22 13:22:45 -07:00
committed by Jon Wayne Parrott
parent d16816051a
commit 9fd860dd4f
2 changed files with 20 additions and 9 deletions

View File

@@ -1008,6 +1008,17 @@ class DecoratorTests(unittest2.TestCase):
# This is never set, but it's consistent with other tests. # This is never set, but it's consistent with other tests.
self.assertFalse(decorator._in_error) self.assertFalse(decorator._in_error)
def test_invalid_state(self):
with mock.patch.object(appengine, '_parse_state_value',
return_value=None, autospec=True):
# Now simulate the callback to /oauth2callback.
response = self.app.get('/oauth2callback', {
'code': 'foo_access_code',
'state': 'foo_path:xsrfkey123',
})
self.assertEqual('200 OK', response.status)
self.assertEqual('The authorization request failed', response.body)
class DecoratorXsrfSecretTests(unittest2.TestCase): class DecoratorXsrfSecretTests(unittest2.TestCase):
"""Test xsrf_secret_key.""" """Test xsrf_secret_key."""

View File

@@ -68,21 +68,21 @@ class TestSQLAlchemyStorage(unittest2.TestCase):
def test_get(self): def test_get(self):
session = self.session() session = self.session()
credentials_storage = oauth2client.contrib.sqlalchemy.Storage(
session=session,
model_class=DummyModel,
key_name='key',
key_value=1,
property_name='credentials',
)
self.assertIsNone(credentials_storage.get())
session.add(DummyModel( session.add(DummyModel(
key=1, key=1,
credentials=self.credentials, credentials=self.credentials,
)) ))
session.commit() session.commit()
credentials = oauth2client.contrib.sqlalchemy.Storage( self.compare_credentials(credentials_storage.get())
session=session,
model_class=DummyModel,
key_name='key',
key_value=1,
property_name='credentials',
).get()
self.compare_credentials(credentials)
def test_put(self): def test_put(self):
session = self.session() session = self.session()