diff options
author | Danny Hermes <daniel.j.hermes@gmail.com> | 2015-09-15 20:55:04 -0700 |
---|---|---|
committer | Danny Hermes <daniel.j.hermes@gmail.com> | 2015-09-15 20:55:04 -0700 |
commit | 64ab3c841f1db1f99f9bf6b87547ec4653e1a937 (patch) | |
tree | 4d52d49c4f3e2e28087d6bfc907b7acdf2ee3dd4 /tests/test_client.py | |
parent | b3febf53bc4e69a557c523242e609da5b2a5427b (diff) | |
download | oauth2client-64ab3c841f1db1f99f9bf6b87547ec4653e1a937.tar.gz |
Removing unused test code.
These are either YAGNI implemented cases or checks that never
get exercised.
In one case (`devshell`) actually made a simple test to make
sure that the consistency checks in the socket server were
doing the expected thing.
Diffstat (limited to 'tests/test_client.py')
-rw-r--r-- | tests/test_client.py | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/tests/test_client.py b/tests/test_client.py index 3a9bd26..3096280 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -33,6 +33,7 @@ import mock import six from six.moves import urllib +from .http_mock import CacheMock from .http_mock import HttpMock from .http_mock import HttpMockSequence from oauth2client import GOOGLE_REVOKE_URI @@ -112,19 +113,6 @@ def load_and_cache(existing_file, fakename, cache_mock): cache_mock.cache[fakename] = {client_type: client_info} -class CacheMock(object): - def __init__(self): - self.cache = {} - - def get(self, key, namespace=''): - # ignoring namespace for easier testing - return self.cache.get(key, None) - - def set(self, key, value, namespace=''): - # ignoring namespace for easier testing - self.cache[key] = value - - class CredentialsTests(unittest.TestCase): def test_to_from_json(self): @@ -133,23 +121,6 @@ class CredentialsTests(unittest.TestCase): restored = Credentials.new_from_json(json) -class MockResponse(object): - """Mock the response of urllib2.urlopen() call.""" - - def __init__(self, headers): - self._headers = headers - - def info(self): - class Info: - def __init__(self, headers): - self.headers = headers - - def get(self, key, default=None): - return self.headers.get(key, default) - - return Info(self._headers) - - @contextlib.contextmanager def mock_module_import(module): """Place a dummy objects in sys.modules to mock an import test.""" @@ -169,27 +140,19 @@ def mock_module_import(module): class GoogleCredentialsTests(unittest.TestCase): def setUp(self): - self.env_server_software = os.environ.get('SERVER_SOFTWARE', None) - self.env_google_application_credentials = ( - os.environ.get(GOOGLE_APPLICATION_CREDENTIALS, None)) - self.env_appdata = os.environ.get('APPDATA', None) self.os_name = os.name from oauth2client import client client.SETTINGS.env_name = None def tearDown(self): - self.reset_env('SERVER_SOFTWARE', self.env_server_software) - self.reset_env(GOOGLE_APPLICATION_CREDENTIALS, - self.env_google_application_credentials) - self.reset_env('APPDATA', self.env_appdata) + self.reset_env('SERVER_SOFTWARE') + self.reset_env(GOOGLE_APPLICATION_CREDENTIALS) + self.reset_env('APPDATA') os.name = self.os_name - def reset_env(self, env, value): + def reset_env(self, env): """Set the environment variable 'env' to 'value'.""" - if value is not None: - os.environ[env] = value - else: - os.environ.pop(env, '') + os.environ.pop(env, None) def validate_service_account_credentials(self, credentials): self.assertTrue(isinstance(credentials, _ServiceAccountCredentials)) @@ -796,7 +759,7 @@ class BasicCredentialsTests(unittest.TestCase): # First, test that we correctly encode basic objects, making sure # to include a bytes object. Note that oauth2client will normalize # everything to bytes, no matter what python version we're in. - http = credentials.authorize(HttpMock(headers={'status': '200'})) + http = credentials.authorize(HttpMock()) headers = {u'foo': 3, b'bar': True, 'baz': b'abc'} cleaned_headers = {b'foo': b'3', b'bar': b'True', b'baz': b'abc'} http.request(u'http://example.com', method=u'GET', headers=headers) @@ -825,7 +788,7 @@ class BasicCredentialsTests(unittest.TestCase): refresh_token, token_expiry, token_uri, user_agent, revoke_uri=revoke_uri) - http = HttpMock(headers={'status': '200'}) + http = HttpMock() http = credentials.authorize(http) http.request(u'http://example.com', method=u'GET', headers={u'foo': u'bar'}) @@ -941,8 +904,6 @@ class AccessTokenCredentialsTests(unittest.TestCase): self.fail('should throw exception if token expires') except AccessTokenCredentialsError: pass - except Exception: - self.fail('should only throw AccessTokenCredentialsError') def test_token_revoke_success(self): _token_revoke_test_helper( |