# Path: invenio_pidstore/proxies.py

# 
# Path: invenio_pidstore/minters.py
# def recid_minter(record_uuid, data):
#     """Mint record identifiers.
# 
#     This is a minter specific for records.
#     With the help of
#     :class:`invenio_pidstore.providers.recordid.RecordIdProvider`, it creates
#     the PID instance with `rec` as predefined `object_type`.
# 
#     Procedure followed: (we will use `control_number` as value of
#     `PIDSTORE_RECID_FIELD` for the simplicity of the documentation.)
# 
#     #. If a `control_number` field is already there, a `AssertionError`
#     exception is raised.
# 
#     #. The provider is initialized with the help of
#     :class:`invenio_pidstore.providers.recordid.RecordIdProvider`.
#     It's called with default value 'rec' for `object_type` and `record_uuid`
#     variable for `object_uuid`.
# 
#     #. The new `id_value` is stored inside `data` as `control_number` field.
# 
#     :param record_uuid: The record UUID.
#     :param data: The record metadata.
#     :returns: A fresh `invenio_pidstore.models.PersistentIdentifier` instance.
#     """
#     pid_field = current_app.config['PIDSTORE_RECID_FIELD']
#     assert pid_field not in data
#     provider = RecordIdProvider.create(
#         object_type='rec', object_uuid=record_uuid)
#     data[pid_field] = provider.pid.pid_value
#     return provider.pid
# 
# def recid_minter_v2(record_uuid, data):
#     """Mint record identifiers with RecordIDProviderV2.
# 
#     This minter is recommended to be used when creating records to get
#     PersistentIdentifier with ``object_type='rec'`` and the new random
#     alphanumeric `pid_value`.
# 
#     Raises ``AssertionError`` if a ``PIDSTORE_RECID_FIELD`` entry is already in
#     ``data``. The minted ``pid_value`` will be stored in that field.
# 
#     :param record_uuid: The object UUID of the record.
#     :param data: The record metadata.
#     :returns: A fresh `invenio_pidstore.models.PersistentIdentifier` instance.
#     """
#     pid_field = current_app.config['PIDSTORE_RECID_FIELD']
#     assert pid_field not in data
#     provider = RecordIdProviderV2.create(
#         object_type='rec', object_uuid=record_uuid)
#     data[pid_field] = provider.pid.pid_value
#     return provider.pid


import pytest
import uuid
from invenio_pidstore import current_pidstore
from invenio_pidstore.minters import recid_minter, recid_minter_v2

        pid = recid_minter(rec_uuid, data)

        assert pid
        assert data[app.config['PIDSTORE_RECID_FIELD']] == pid.pid_value
        assert pid.object_type == 'rec'
        assert pid.object_uuid == rec_uuid


def test_recid_minter_v2(app, db):
    """Test recommended recid minter."""
    with app.app_context():
        rec_uuid = uuid.uuid4()
        data = {}
        recid_field = app.config['PIDSTORE_RECID_FIELD']

        pid = recid_minter_v2(rec_uuid, data)

        assert pid
        assert data[recid_field] == pid.pid_value
        assert pid.object_type == 'rec'
        assert pid.object_uuid == rec_uuid

        with pytest.raises(AssertionError):
            recid_minter_v2(rec_uuid, {recid_field: '1'})


def test_register_minter(app):
    """Test base provider."""
    with app.app_context():

# Path: invenio_pidstore/proxies.py

# 
# Path: invenio_pidstore/minters.py
# def recid_minter(record_uuid, data):
#     """Mint record identifiers.
# 
#     This is a minter specific for records.
#     With the help of
#     :class:`invenio_pidstore.providers.recordid.RecordIdProvider`, it creates
#     the PID instance with `rec` as predefined `object_type`.
# 
#     Procedure followed: (we will use `control_number` as value of
#     `PIDSTORE_RECID_FIELD` for the simplicity of the documentation.)
# 
#     #. If a `control_number` field is already there, a `AssertionError`
#     exception is raised.
# 
#     #. The provider is initialized with the help of
#     :class:`invenio_pidstore.providers.recordid.RecordIdProvider`.
#     It's called with default value 'rec' for `object_type` and `record_uuid`
#     variable for `object_uuid`.
# 
#     #. The new `id_value` is stored inside `data` as `control_number` field.
# 
#     :param record_uuid: The record UUID.
#     :param data: The record metadata.
#     :returns: A fresh `invenio_pidstore.models.PersistentIdentifier` instance.
#     """
#     pid_field = current_app.config['PIDSTORE_RECID_FIELD']
#     assert pid_field not in data
#     provider = RecordIdProvider.create(
#         object_type='rec', object_uuid=record_uuid)
#     data[pid_field] = provider.pid.pid_value
#     return provider.pid
# 
# def recid_minter_v2(record_uuid, data):
#     """Mint record identifiers with RecordIDProviderV2.
# 
#     This minter is recommended to be used when creating records to get
#     PersistentIdentifier with ``object_type='rec'`` and the new random
#     alphanumeric `pid_value`.
# 
#     Raises ``AssertionError`` if a ``PIDSTORE_RECID_FIELD`` entry is already in
#     ``data``. The minted ``pid_value`` will be stored in that field.
# 
#     :param record_uuid: The object UUID of the record.
#     :param data: The record metadata.
#     :returns: A fresh `invenio_pidstore.models.PersistentIdentifier` instance.
#     """
#     pid_field = current_app.config['PIDSTORE_RECID_FIELD']
#     assert pid_field not in data
#     provider = RecordIdProviderV2.create(
#         object_type='rec', object_uuid=record_uuid)
#     data[pid_field] = provider.pid.pid_value
#     return provider.pid


# Path: tests/test_minters.py
import pytest
import uuid
from invenio_pidstore import current_pidstore
from invenio_pidstore.minters import recid_minter, recid_minter_v2


        pid = recid_minter(rec_uuid, data)

        assert pid
        assert data[app.config['PIDSTORE_RECID_FIELD']] == pid.pid_value
        assert pid.object_type == 'rec'
        assert pid.object_uuid == rec_uuid


def test_recid_minter_v2(app, db):
    """Test recommended recid minter."""
    with app.app_context():
        rec_uuid = uuid.uuid4()
        data = {}
        recid_field = app.config['PIDSTORE_RECID_FIELD']

        pid = recid_minter_v2(rec_uuid, data)

        assert pid
        assert data[recid_field] == pid.pid_value
        assert pid.object_type == 'rec'
        assert pid.object_uuid == rec_uuid

        with pytest.raises(AssertionError):
            recid_minter_v2(rec_uuid, {recid_field: '1'})


def test_register_minter(app):
    """Test base provider."""
    with app.app_context():

        current_pidstore.register_minter('anothername', recid_minter)