Skip to content

Commit

Permalink
Invenio pid mapping (#265)
Browse files Browse the repository at this point in the history
* pid mapping

* tests, not generating pid class

* Fixed tests
  • Loading branch information
mesemus authored Jul 9, 2024
1 parent 707ac44 commit 81271be
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 4 deletions.
66 changes: 63 additions & 3 deletions oarepo_model_builder/builtin_models/invenio.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"marshmallow": {
"base-classes": ["oarepo_runtime.services.schema.marshmallow.BaseRecordSchema"],
"imports": []
"base-classes": [
"oarepo_runtime.services.schema.marshmallow.BaseRecordSchema"
],
"imports": []
},
"ui": {
"marshmallow": {
"base-classes": ["oarepo_runtime.services.schema.ui.InvenioUISchema"],
"base-classes": [
"oarepo_runtime.services.schema.ui.InvenioUISchema"
],
"imports": []
}
},
Expand Down Expand Up @@ -70,6 +74,62 @@
}
}
},
"pid": {
"type": "object",
"marshmallow": {
"generate": false,
"write": false,
"read": false,
"skip": true,
"class": "FakePIDSchema"
},
"ui": {
"marshmallow": {
"generate": false,
"write": false,
"read": false,
"skip": true,
"class": "FakeUIPIDSchema"
}
},
"facets": {
"searchable": true,
"facet": false
},
"sample": {
"skip": true
},
"properties": {
"obj_type": {
"type": "keyword",
"facets": {
"searchable": true,
"facet": false
}
},
"pid_type": {
"type": "keyword",
"facets": {
"searchable": true,
"facet": false
}
},
"pk": {
"type": "integer",
"facets": {
"searchable": true,
"facet": false
}
},
"status": {
"type": "keyword",
"facets": {
"searchable": true,
"facet": false
}
}
}
},
"$schema": {
"type": "keyword",
"marshmallow": {
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.85
version = 4.0.86
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down
9 changes: 9 additions & 0 deletions tests/test_builder_from_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ class Meta:
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
},
"id": {"type": "keyword", "ignore_above": 1024},
"pid": {
"properties": {
"obj_type": {"ignore_above": 1024, "type": "keyword"},
"pid_type": {"ignore_above": 1024, "type": "keyword"},
"pk": {"type": "integer"},
"status": {"ignore_above": 1024, "type": "keyword"},
},
"type": "object",
},
"updated": {
"type": "date",
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
Expand Down
39 changes: 39 additions & 0 deletions tests/test_model_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,45 @@ def test_model_saver_invenio():
"ui": {"marshmallow": {"read": False, "write": False}},
"sample": {"skip": True},
},
"pid": {
"facets": {"facet": False, "searchable": True},
"marshmallow": {
"class": "test.services.records.schema.FakePIDSchema",
"generate": False,
"read": False,
"skip": True,
"write": False,
},
"sample": {"skip": True},
"properties": {
"obj_type": {
"facets": {"facet": False, "searchable": True},
"type": "keyword",
},
"pid_type": {
"facets": {"facet": False, "searchable": True},
"type": "keyword",
},
"pk": {
"facets": {"facet": False, "searchable": True},
"type": "integer",
},
"status": {
"facets": {"facet": False, "searchable": True},
"type": "keyword",
},
},
"type": "object",
"ui": {
"marshmallow": {
"class": "test.services.records.ui_schema.FakeUIPIDSchema",
"generate": False,
"read": False,
"skip": True,
"write": False,
}
},
},
"updated": {
"type": "datetime",
"facets": {"searchable": True, "facet": False},
Expand Down
18 changes: 18 additions & 0 deletions tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class Meta:
"properties": {
"a": {"type": "flat_object"},
"id": {"type": "keyword", "ignore_above": 1024},
"pid": {
"properties": {
"obj_type": {"ignore_above": 1024, "type": "keyword"},
"pid_type": {"ignore_above": 1024, "type": "keyword"},
"pk": {"type": "integer"},
"status": {"ignore_above": 1024, "type": "keyword"},
},
"type": "object",
},
"created": {
"type": "date",
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
Expand All @@ -76,6 +85,15 @@ class Meta:
"properties": {
"a": {"type": "object"},
"id": {"type": "string"},
"pid": {
"properties": {
"obj_type": {"type": "string"},
"pid_type": {"type": "string"},
"pk": {"type": "integer"},
"status": {"type": "string"},
},
"type": "object",
},
"created": {"type": "string", "format": "date-time"},
"updated": {"type": "string", "format": "date-time"},
"$schema": {"type": "string"},
Expand Down
18 changes: 18 additions & 0 deletions tests/test_schema_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ class Meta:
"a": {"type": "string"},
"created": {"format": "date-time", "type": "string"},
"id": {"type": "string"},
"pid": {
"properties": {
"obj_type": {"type": "string"},
"pid_type": {"type": "string"},
"pk": {"type": "integer"},
"status": {"type": "string"},
},
"type": "object",
},
"updated": {"format": "date-time", "type": "string"},
},
"type": "object",
Expand All @@ -91,6 +100,15 @@ class Meta:
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
},
"id": {"type": "keyword", "ignore_above": 1024},
"pid": {
"properties": {
"obj_type": {"ignore_above": 1024, "type": "keyword"},
"pid_type": {"ignore_above": 1024, "type": "keyword"},
"pk": {"type": "integer"},
"status": {"ignore_above": 1024, "type": "keyword"},
},
"type": "object",
},
"updated": {
"type": "date",
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
Expand Down
18 changes: 18 additions & 0 deletions tests/test_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ class Meta:
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
},
"id": {"type": "keyword", "ignore_above": 1024},
"pid": {
"properties": {
"obj_type": {"ignore_above": 1024, "type": "keyword"},
"pid_type": {"ignore_above": 1024, "type": "keyword"},
"pk": {"type": "integer"},
"status": {"ignore_above": 1024, "type": "keyword"},
},
"type": "object",
},
"updated": {
"type": "date",
"format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
Expand All @@ -79,6 +88,15 @@ class Meta:
"a": {"items": {"type": "string"}, "type": "array"},
"created": {"format": "date-time", "type": "string"},
"id": {"type": "string"},
"pid": {
"properties": {
"obj_type": {"type": "string"},
"pid_type": {"type": "string"},
"pk": {"type": "integer"},
"status": {"type": "string"},
},
"type": "object",
},
"updated": {"format": "date-time", "type": "string"},
},
"type": "object",
Expand Down

0 comments on commit 81271be

Please sign in to comment.