# -*- coding: utf-8 -*-
#
# This file is part of the shibboleth-authenticator module for Invenio.
# Copyright (C) 2017  Helmholtz-Zentrum Dresden-Rossendorf
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""Test helpers."""


from __future__ import absolute_import

from flask import Flask

from shibboleth_authenticator import ShibbolethAuthenticator


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


def test_init():
    """Test extension initialization."""
    app = Flask('testapp')
    ext = ShibbolethAuthenticator(app)
    assert 'shibboleth-authenticator' in app.extensions

    app = Flask('testapp')
    ext = ShibbolethAuthenticator()
    assert 'shibboleth-authenticator' not in app.extensions
    ext.init_app(app)
    assert 'shibboleth-authenticator' in app.extensions

    # Check if configurations is read properly.
    assert 'SHIBBOLETH_REMOTE_APPS' in app.config
