# Path: zenodo/modules/openaire/helpers.py
# def openaire_id(record):
#     """Compute the OpenAIRE identifier."""
#     return _openaire_id(record, openaire_type(record))
# 
# def openaire_link(record):
#     """Compute an OpenAIRE link."""
#     oatype = openaire_type(record)
#     doi = record.get('doi')
# 
#     if oatype == _OAType.publication:
#         return '{}/search/publication?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.dataset:
#         return '{}/search/dataset?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.software:
#         return '{}/search/software?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.other:
#         return '{}/search/other?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     return None
# 
# def openaire_type(record):
#     """Get the OpenAIRE type of a record."""
#     if is_openaire_publication(record):
#         return _OAType.publication
#     elif is_openaire_dataset(record):
#         return _OAType.dataset
#     elif is_openaire_software(record):
#         return _OAType.software
#     elif is_openaire_other(record):
#         return _OAType.other
#     return None


from zenodo.modules.openaire.helpers import openaire_id, openaire_link, \
    openaire_type
# License, or (at your option) any later version.
#
# Zenodo 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 Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

"""Test for OpenAIRE helpers."""

from __future__ import absolute_import, print_function



def test_openaire_type(app, minimal_record):
    """Test OpenAIRE type."""
    r = minimal_record
    # Default zenodo type is software.
    assert openaire_type(r) == 'software'

    # Other type
    r['resource_type']['type'] = 'other'

# Path: zenodo/modules/openaire/helpers.py
# def openaire_id(record):
#     """Compute the OpenAIRE identifier."""
#     return _openaire_id(record, openaire_type(record))
# 
# def openaire_link(record):
#     """Compute an OpenAIRE link."""
#     oatype = openaire_type(record)
#     doi = record.get('doi')
# 
#     if oatype == _OAType.publication:
#         return '{}/search/publication?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.dataset:
#         return '{}/search/dataset?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.software:
#         return '{}/search/software?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     elif oatype == _OAType.other:
#         return '{}/search/other?pid={}'.format(
#             current_app.config['OPENAIRE_PORTAL_URL'],
#             urllib.quote(doi),
#         )
#     return None
# 
# def openaire_type(record):
#     """Get the OpenAIRE type of a record."""
#     if is_openaire_publication(record):
#         return _OAType.publication
#     elif is_openaire_dataset(record):
#         return _OAType.dataset
#     elif is_openaire_software(record):
#         return _OAType.software
#     elif is_openaire_other(record):
#         return _OAType.other
#     return None


# Path: tests/unit/openaire/test_openaire_helpers.py
from zenodo.modules.openaire.helpers import openaire_id, openaire_link, \
    openaire_type

# License, or (at your option) any later version.
#
# Zenodo 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 Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

"""Test for OpenAIRE helpers."""

from __future__ import absolute_import, print_function



def test_openaire_type(app, minimal_record):
    """Test OpenAIRE type."""
    r = minimal_record
    # Default zenodo type is software.
    assert openaire_type(r) == 'software'

    # Other type
    r['resource_type']['type'] = 'other'

    assert openaire_type(r) == 'other'