diff --git a/oarepo_model_builder/builtin_models/doi.json b/oarepo_model_builder/builtin_models/doi.json new file mode 100644 index 0000000..9f0757c --- /dev/null +++ b/oarepo_model_builder/builtin_models/doi.json @@ -0,0 +1,7 @@ +{ + "service-config": { + "components": [ + "{{oarepo_doi.services.components.DoiComponent}}" + ] + } +} \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 7ed33eb..7f872b0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -93,6 +93,7 @@ oarepo_model_builder.datatypes.components = # models are generic, same for all profiles oarepo.models = invenio = oarepo_model_builder.builtin_models:invenio.json + doi = oarepo_model_builder.builtin_models:doi.json # outputs are generic, profile independent diff --git a/tests/test_include_doi.py b/tests/test_include_doi.py new file mode 100644 index 0000000..62e4e1e --- /dev/null +++ b/tests/test_include_doi.py @@ -0,0 +1,39 @@ +import os +import re + +from oarepo_model_builder.entrypoints import create_builder_from_entrypoints, load_model +from oarepo_model_builder.fs import InMemoryFileSystem + +from .utils import strip_whitespaces + +OAREPO_USE = "use" + + + +def test_include_invenio(): + schema = load_model( + "test.yaml", # NOSONAR + model_content={ + "version": "1.0.0", + + "record": { + "module": {"qualified": "test"}, + OAREPO_USE: ["invenio", "doi"], + "properties": {"a": {"type": "keyword", "required": True}}, + }, + }, + isort=False, + black=False, + autoflake=False, + ) + + filesystem = InMemoryFileSystem() + builder = create_builder_from_entrypoints(filesystem=filesystem) + + builder.build(schema, "record", ["record"], "") + + data = builder.filesystem.open( + os.path.join("test", "services", "records", "config.py") + ).read() + data = str(data) + assert "components=[*PermissionsPresetsConfigMixin.components,*InvenioRecordServiceConfig.components,DoiComponent]" in re.sub(r"\s", "", data) \ No newline at end of file