# Path: invenio_oauthclient/ext.py
# class InvenioOAuthClient(object):
#     """Invenio Oauthclient extension."""
# 
#     def __init__(self, app=None):
#         """Extension initialization."""
#         if app:
#             self._state = self.init_app(app)
# 
#     def init_app(self, app):
#         """Flask application initialization."""
#         self.init_config(app)
#         state = _OAuthClientState(
#             app, 'OAUTHCLIENT_REMOTE_APPS',
#             handlers.disconnect_handler,
#             handlers.authorized_default_handler)
#         app.extensions['invenio-oauthclient'] = state
#         return state
# 
#     def init_config(self, app):
#         """Initialize configuration."""
#         @app.before_first_request
#         def override_template_configuration():
#             """Override template configuration."""
#             template_key = app.config.get(
#                 'OAUTHCLIENT_TEMPLATE_KEY',
#                 'SECURITY_LOGIN_USER_TEMPLATE'  # default template key
#             )
#             if template_key is not None:
#                 template = app.config[template_key]  # keep the old value
#                 app.config['OAUTHCLIENT_LOGIN_USER_TEMPLATE_PARENT'] = template
#                 app.config[template_key] = app.config.get(
#                     'OAUTHCLIENT_LOGIN_USER_TEMPLATE',
#                     'invenio_oauthclient/login_user.html'
#                 )
# 
# Path: invenio_oauthclient/contrib/orcid.py
# REMOTE_APP = _orcid_app.remote_app


import os
import pytest
from copy import deepcopy
from flask import Flask
from flask_oauthlib.client import OAuth as FlaskOAuth
from flask_oauthlib.client import OAuthRemoteApp
from invenio_db import InvenioDB, db
from sqlalchemy_utils.functions import create_database, database_exists
from invenio_oauthclient import InvenioOAuthClient
from invenio_oauthclient.contrib.orcid import REMOTE_APP
    from invenio_oauthclient import __version__
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Test helpers."""





def test_version():
    """Test version import."""
    assert __version__


def test_init():
    """Test extension initialization."""
    app = Flask('testapp')
    FlaskOAuth(app)
    ext = InvenioOAuthClient(app)
    assert 'invenio-oauthclient' in app.extensions

    app = Flask('testapp')
    ext = InvenioOAuthClient(app)
    assert 'invenio-oauthclient' in app.extensions

    app = Flask('testapp')
    FlaskOAuth(app)

# Path: invenio_oauthclient/ext.py
# class InvenioOAuthClient(object):
#     """Invenio Oauthclient extension."""
# 
#     def __init__(self, app=None):
#         """Extension initialization."""
#         if app:
#             self._state = self.init_app(app)
# 
#     def init_app(self, app):
#         """Flask application initialization."""
#         self.init_config(app)
#         state = _OAuthClientState(
#             app, 'OAUTHCLIENT_REMOTE_APPS',
#             handlers.disconnect_handler,
#             handlers.authorized_default_handler)
#         app.extensions['invenio-oauthclient'] = state
#         return state
# 
#     def init_config(self, app):
#         """Initialize configuration."""
#         @app.before_first_request
#         def override_template_configuration():
#             """Override template configuration."""
#             template_key = app.config.get(
#                 'OAUTHCLIENT_TEMPLATE_KEY',
#                 'SECURITY_LOGIN_USER_TEMPLATE'  # default template key
#             )
#             if template_key is not None:
#                 template = app.config[template_key]  # keep the old value
#                 app.config['OAUTHCLIENT_LOGIN_USER_TEMPLATE_PARENT'] = template
#                 app.config[template_key] = app.config.get(
#                     'OAUTHCLIENT_LOGIN_USER_TEMPLATE',
#                     'invenio_oauthclient/login_user.html'
#                 )
# 
# Path: invenio_oauthclient/contrib/orcid.py
# REMOTE_APP = _orcid_app.remote_app


# Path: tests/test_app.py
import os
import pytest
from copy import deepcopy
from flask import Flask
from flask_oauthlib.client import OAuth as FlaskOAuth
from flask_oauthlib.client import OAuthRemoteApp
from invenio_db import InvenioDB, db
from sqlalchemy_utils.functions import create_database, database_exists
from invenio_oauthclient import InvenioOAuthClient
from invenio_oauthclient.contrib.orcid import REMOTE_APP
    from invenio_oauthclient import __version__

# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Test helpers."""





def test_version():
    """Test version import."""
    assert __version__


def test_init():
    """Test extension initialization."""
    app = Flask('testapp')
    FlaskOAuth(app)
    ext = InvenioOAuthClient(app)
    assert 'invenio-oauthclient' in app.extensions

    app = Flask('testapp')
    ext = InvenioOAuthClient(app)
    assert 'invenio-oauthclient' in app.extensions

    app = Flask('testapp')
    FlaskOAuth(app)

    ext = InvenioOAuthClient()