# Path: google/auth/_oauth2client.py
#     _HAS_APPENGINE = True
#     _HAS_APPENGINE = False
# _CONVERT_ERROR_TMPL = "Unable to convert {} to a google-auth credentials class."
# _CLASS_CONVERSION_MAP = {
#     oauth2client.client.OAuth2Credentials: _convert_oauth2_credentials,
#     oauth2client.client.GoogleCredentials: _convert_oauth2_credentials,
#     oauth2client.service_account.ServiceAccountCredentials: _convert_service_account_credentials,
#     oauth2client.service_account._JWTAccessCredentials: _convert_service_account_credentials,
#     oauth2client.contrib.gce.AppAssertionCredentials: _convert_gce_app_assertion_credentials,
# }
# def _convert_oauth2_credentials(credentials):
# def _convert_service_account_credentials(credentials):
# def _convert_gce_app_assertion_credentials(credentials):
# def _convert_appengine_app_assertion_credentials(credentials):
# def convert(credentials):


import datetime
import os
import sys
import mock
import oauth2client.client  # type: ignore
import oauth2client.contrib.gce  # type: ignore
import oauth2client.service_account  # type: ignore
import pytest  # type: ignore
    import oauth2client.contrib.appengine  # type: ignore
from six.moves import reload_module
from google.auth import _oauth2client
def test_convert_success():
    convert_function = mock.Mock(spec=["__call__"])
    conversion_map_patch = mock.patch.object(
        _oauth2client, "_CLASS_CONVERSION_MAP", {FakeCredentials: convert_function}
    )
    credentials = FakeCredentials()

    with conversion_map_patch:
        result = _oauth2client.convert(credentials)

    convert_function.assert_called_once_with(credentials)
    assert result == convert_function.return_value


def test_convert_not_found():
    with pytest.raises(ValueError) as excinfo:
        _oauth2client.convert("a string is not a real credentials class")

    assert excinfo.match("Unable to convert")


@pytest.fixture
def reset__oauth2client_module():
    """Reloads the _oauth2client module after a test."""
    reload_module(_oauth2client)


def test_import_has_app_engine(
    mock_oauth2client_gae_imports, reset__oauth2client_module
):

# Path: google/auth/_oauth2client.py
#     _HAS_APPENGINE = True
#     _HAS_APPENGINE = False
# _CONVERT_ERROR_TMPL = "Unable to convert {} to a google-auth credentials class."
# _CLASS_CONVERSION_MAP = {
#     oauth2client.client.OAuth2Credentials: _convert_oauth2_credentials,
#     oauth2client.client.GoogleCredentials: _convert_oauth2_credentials,
#     oauth2client.service_account.ServiceAccountCredentials: _convert_service_account_credentials,
#     oauth2client.service_account._JWTAccessCredentials: _convert_service_account_credentials,
#     oauth2client.contrib.gce.AppAssertionCredentials: _convert_gce_app_assertion_credentials,
# }
# def _convert_oauth2_credentials(credentials):
# def _convert_service_account_credentials(credentials):
# def _convert_gce_app_assertion_credentials(credentials):
# def _convert_appengine_app_assertion_credentials(credentials):
# def convert(credentials):


# Path: tests/test__oauth2client.py
import datetime
import os
import sys
import mock
import oauth2client.client  # type: ignore
import oauth2client.contrib.gce  # type: ignore
import oauth2client.service_account  # type: ignore
import pytest  # type: ignore
    import oauth2client.contrib.appengine  # type: ignore
from six.moves import reload_module
from google.auth import _oauth2client

def test_convert_success():
    convert_function = mock.Mock(spec=["__call__"])
    conversion_map_patch = mock.patch.object(
        _oauth2client, "_CLASS_CONVERSION_MAP", {FakeCredentials: convert_function}
    )
    credentials = FakeCredentials()

    with conversion_map_patch:
        result = _oauth2client.convert(credentials)

    convert_function.assert_called_once_with(credentials)
    assert result == convert_function.return_value


def test_convert_not_found():
    with pytest.raises(ValueError) as excinfo:
        _oauth2client.convert("a string is not a real credentials class")

    assert excinfo.match("Unable to convert")


@pytest.fixture
def reset__oauth2client_module():
    """Reloads the _oauth2client module after a test."""
    reload_module(_oauth2client)


def test_import_has_app_engine(
    mock_oauth2client_gae_imports, reset__oauth2client_module
):

    reload_module(_oauth2client)