invenio-app-ils 4.6.0__py2.py3-none-any.whl → 5.0.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- invenio_app_ils/__init__.py +1 -1
- invenio_app_ils/assets/semantic-ui/less/theme.config +103 -0
- invenio_app_ils/circulation/api.py +9 -5
- invenio_app_ils/circulation/config.py +1 -0
- invenio_app_ils/circulation/loaders/schemas/json/loan_checkout.py +1 -1
- invenio_app_ils/circulation/loaders/schemas/json/loan_request.py +2 -2
- invenio_app_ils/circulation/notifications/api.py +9 -1
- invenio_app_ils/circulation/notifications/messages.py +2 -1
- invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/update_dates.html +19 -0
- invenio_app_ils/cli.py +92 -64
- invenio_app_ils/config.py +10 -2
- invenio_app_ils/documents/loaders/jsonschemas/document.py +1 -1
- invenio_app_ils/eitems/loaders/jsonschemas/eitems.py +2 -2
- invenio_app_ils/patrons/anonymization.py +0 -4
- invenio_app_ils/series/loaders/jsonschemas/series.py +1 -1
- invenio_app_ils/webpack.py +27 -0
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/METADATA +52 -42
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/RECORD +24 -112
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/entry_points.txt +3 -0
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/top_level.txt +0 -1
- invenio_app_ils/notifications/admin.py +0 -57
- tests/__init__.py +0 -8
- tests/api/__init__.py +0 -8
- tests/api/acquisition/__init__.py +0 -8
- tests/api/acquisition/test_acq_orders_crud.py +0 -99
- tests/api/acquisition/test_acq_orders_permissions.py +0 -104
- tests/api/acquisition/test_acq_providers_permissions.py +0 -83
- tests/api/circulation/__init__.py +0 -8
- tests/api/circulation/test_expired_loans.py +0 -88
- tests/api/circulation/test_loan_bulk_extend.py +0 -169
- tests/api/circulation/test_loan_checkout.py +0 -422
- tests/api/circulation/test_loan_default_durations.py +0 -43
- tests/api/circulation/test_loan_document_resolver.py +0 -18
- tests/api/circulation/test_loan_extend.py +0 -122
- tests/api/circulation/test_loan_item_permissions.py +0 -135
- tests/api/circulation/test_loan_item_resolver.py +0 -26
- tests/api/circulation/test_loan_list_permissions.py +0 -98
- tests/api/circulation/test_loan_patron_resolver.py +0 -38
- tests/api/circulation/test_loan_request.py +0 -338
- tests/api/circulation/test_loan_update.py +0 -150
- tests/api/circulation/test_notifications.py +0 -221
- tests/api/conftest.py +0 -227
- tests/api/document_requests/__init__.py +0 -8
- tests/api/document_requests/test_document_requests.py +0 -131
- tests/api/document_requests/test_document_requests_permissions.py +0 -159
- tests/api/document_requests/test_notifications_filter.py +0 -35
- tests/api/ill/__init__.py +0 -8
- tests/api/ill/test_ill_brw_crud.py +0 -74
- tests/api/ill/test_ill_brw_reqs_patron_loan_create_action.py +0 -198
- tests/api/ill/test_ill_brw_reqs_patron_loan_extension_actions.py +0 -280
- tests/api/ill/test_ill_brw_reqs_permissions.py +0 -163
- tests/api/ill/test_ill_providers_permissions.py +0 -82
- tests/api/ils/__init__.py +0 -8
- tests/api/ils/documents/__init__.py +0 -8
- tests/api/ils/documents/test_document_crud.py +0 -57
- tests/api/ils/documents/test_document_permissions.py +0 -100
- tests/api/ils/documents/test_document_resolvers.py +0 -35
- tests/api/ils/eitems/__init__.py +0 -8
- tests/api/ils/eitems/test_eitems_crud.py +0 -42
- tests/api/ils/eitems/test_eitems_permissions.py +0 -85
- tests/api/ils/eitems/test_files.py +0 -162
- tests/api/ils/items/__init__.py +0 -8
- tests/api/ils/items/test_apis.py +0 -43
- tests/api/ils/items/test_items_crud.py +0 -99
- tests/api/ils/items/test_items_permissions.py +0 -107
- tests/api/ils/records_relations/__init__.py +0 -8
- tests/api/ils/records_relations/helpers.py +0 -115
- tests/api/ils/records_relations/test_records_relations_parentchild.py +0 -560
- tests/api/ils/records_relations/test_records_relations_sequence.py +0 -294
- tests/api/ils/records_relations/test_records_relations_siblings.py +0 -751
- tests/api/ils/series/__init__.py +0 -8
- tests/api/ils/series/test_series_permissions.py +0 -95
- tests/api/ils/test_anonymization.py +0 -181
- tests/api/ils/test_apis.py +0 -76
- tests/api/ils/test_closures.py +0 -353
- tests/api/ils/test_errors.py +0 -125
- tests/api/ils/test_facets.py +0 -88
- tests/api/ils/test_internal_locations.py +0 -96
- tests/api/ils/test_loaders.py +0 -51
- tests/api/ils/test_metadata_extensions.py +0 -206
- tests/api/ils/test_notifications.py +0 -173
- tests/api/ils/test_notifications_mails.py +0 -37
- tests/api/ils/test_notifications_permissions.py +0 -55
- tests/api/ils/test_patrons.py +0 -102
- tests/api/ils/test_record_delete.py +0 -42
- tests/api/ils/test_record_permissions.py +0 -132
- tests/api/ils/test_resolvers.py +0 -205
- tests/api/ils/test_stats.py +0 -142
- tests/api/ils/test_tasks.py +0 -209
- tests/api/ils/test_vocabularies.py +0 -35
- tests/conftest.py +0 -221
- tests/data/acq_orders.json +0 -110
- tests/data/acq_providers.json +0 -12
- tests/data/document_requests.json +0 -77
- tests/data/documents.json +0 -238
- tests/data/eitems.json +0 -71
- tests/data/ill_borrowing_requests.json +0 -77
- tests/data/ill_providers.json +0 -12
- tests/data/internal_locations.json +0 -22
- tests/data/items.json +0 -304
- tests/data/loans.json +0 -133
- tests/data/loans_most_loaned.json +0 -128
- tests/data/locations.json +0 -26
- tests/data/series.json +0 -33
- tests/helpers.py +0 -107
- tests/templates/notifications/title_body.html +0 -8
- tests/templates/notifications/title_body_html.html +0 -13
- tests/templates/notifications/title_body_html_ctx.html +0 -13
- tests/templates/notifications/title_only.html +0 -3
- tests/test_post_logout_redirect.py +0 -23
- tests/test_version.py +0 -17
- /tests/templates/notifications/blank.html → /invenio_app_ils/assets/semantic-ui/templates/.gitkeep +0 -0
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/WHEEL +0 -0
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {invenio_app_ils-4.6.0.dist-info → invenio_app_ils-5.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,751 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2020 CERN.
|
|
4
|
-
#
|
|
5
|
-
# invenio-app-ils is free software; you can redistribute it and/or modify it
|
|
6
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
"""Test records relations siblings."""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
|
|
12
|
-
from flask import url_for
|
|
13
|
-
|
|
14
|
-
from invenio_app_ils.documents.api import Document
|
|
15
|
-
from tests.helpers import get_test_record, user_login
|
|
16
|
-
|
|
17
|
-
from .helpers import (
|
|
18
|
-
recrel_assert_record_relations,
|
|
19
|
-
recrel_choose_endpoints_and_do_request,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _test_sibl_language_relation(client, json_headers):
|
|
24
|
-
"""Test creation/deletion siblings language relations."""
|
|
25
|
-
first_pid_value = "docid-1"
|
|
26
|
-
first_pid_type = "docid"
|
|
27
|
-
second_pid_value = "docid-2"
|
|
28
|
-
second_pid_type = "docid"
|
|
29
|
-
third_pid_value = "docid-6"
|
|
30
|
-
third_pid_type = "docid"
|
|
31
|
-
relation_type = "language"
|
|
32
|
-
|
|
33
|
-
payload = [
|
|
34
|
-
{
|
|
35
|
-
"pid_value": second_pid_value,
|
|
36
|
-
"pid_type": second_pid_type,
|
|
37
|
-
"relation_type": relation_type,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"pid_value": third_pid_value,
|
|
41
|
-
"pid_type": third_pid_type,
|
|
42
|
-
"relation_type": relation_type,
|
|
43
|
-
},
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
def _test_create():
|
|
47
|
-
"""Test relation creation."""
|
|
48
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
49
|
-
(client, json_headers, "POST"),
|
|
50
|
-
(
|
|
51
|
-
first_pid_value,
|
|
52
|
-
first_pid_type,
|
|
53
|
-
second_pid_value,
|
|
54
|
-
second_pid_type,
|
|
55
|
-
),
|
|
56
|
-
payload,
|
|
57
|
-
)
|
|
58
|
-
rec3 = Document.get_record_by_pid(third_pid_value)
|
|
59
|
-
rec3 = rec3.replace_refs()
|
|
60
|
-
recrel_assert_record_relations(
|
|
61
|
-
rec1,
|
|
62
|
-
expected={
|
|
63
|
-
"relations": {
|
|
64
|
-
"language": [
|
|
65
|
-
{
|
|
66
|
-
"pid_value": second_pid_value,
|
|
67
|
-
"pid_type": second_pid_type,
|
|
68
|
-
"relation_type": "language",
|
|
69
|
-
"record_metadata": {
|
|
70
|
-
"title": rec2["title"],
|
|
71
|
-
"languages": rec2["languages"],
|
|
72
|
-
"document_type": rec2["document_type"],
|
|
73
|
-
"publication_year": rec2["publication_year"],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"pid_value": third_pid_value,
|
|
78
|
-
"pid_type": third_pid_type,
|
|
79
|
-
"relation_type": "language",
|
|
80
|
-
"record_metadata": {
|
|
81
|
-
"title": rec3["title"],
|
|
82
|
-
"document_type": rec3["document_type"],
|
|
83
|
-
"languages": rec3["languages"],
|
|
84
|
-
"publication_year": rec3["publication_year"],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
)
|
|
91
|
-
recrel_assert_record_relations(
|
|
92
|
-
rec2,
|
|
93
|
-
expected={
|
|
94
|
-
"relations": {
|
|
95
|
-
"language": [
|
|
96
|
-
{
|
|
97
|
-
"pid_value": first_pid_value,
|
|
98
|
-
"pid_type": first_pid_type,
|
|
99
|
-
"relation_type": "language",
|
|
100
|
-
"record_metadata": {
|
|
101
|
-
"title": rec1["title"],
|
|
102
|
-
"languages": rec1["languages"],
|
|
103
|
-
"edition": rec1["edition"],
|
|
104
|
-
"document_type": rec1["document_type"],
|
|
105
|
-
"publication_year": rec1["publication_year"],
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"pid_value": third_pid_value,
|
|
110
|
-
"pid_type": third_pid_type,
|
|
111
|
-
"relation_type": "language",
|
|
112
|
-
"record_metadata": {
|
|
113
|
-
"title": rec3["title"],
|
|
114
|
-
"languages": rec3["languages"],
|
|
115
|
-
"document_type": rec3["document_type"],
|
|
116
|
-
"publication_year": rec3["publication_year"],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
)
|
|
123
|
-
recrel_assert_record_relations(
|
|
124
|
-
rec3,
|
|
125
|
-
expected={
|
|
126
|
-
"relations": {
|
|
127
|
-
"language": [
|
|
128
|
-
{
|
|
129
|
-
"pid_value": first_pid_value,
|
|
130
|
-
"pid_type": first_pid_type,
|
|
131
|
-
"relation_type": "language",
|
|
132
|
-
"record_metadata": {
|
|
133
|
-
"title": rec1["title"],
|
|
134
|
-
"languages": rec1["languages"],
|
|
135
|
-
"edition": rec1["edition"],
|
|
136
|
-
"document_type": rec1["document_type"],
|
|
137
|
-
"publication_year": rec1["publication_year"],
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"pid_value": second_pid_value,
|
|
142
|
-
"pid_type": second_pid_type,
|
|
143
|
-
"relation_type": "language",
|
|
144
|
-
"record_metadata": {
|
|
145
|
-
"title": rec2["title"],
|
|
146
|
-
"languages": rec2["languages"],
|
|
147
|
-
"document_type": rec2["document_type"],
|
|
148
|
-
"publication_year": rec2["publication_year"],
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
def _test_delete():
|
|
157
|
-
"""Test relation deletion."""
|
|
158
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
159
|
-
(client, json_headers, "DELETE"),
|
|
160
|
-
(
|
|
161
|
-
first_pid_value,
|
|
162
|
-
first_pid_type,
|
|
163
|
-
second_pid_value,
|
|
164
|
-
second_pid_type,
|
|
165
|
-
),
|
|
166
|
-
payload,
|
|
167
|
-
)
|
|
168
|
-
rec3 = Document.get_record_by_pid(third_pid_value)
|
|
169
|
-
rec3 = rec3.replace_refs()
|
|
170
|
-
recrel_assert_record_relations(rec1, expected={"relations": {}})
|
|
171
|
-
recrel_assert_record_relations(rec2, expected={"relations": {}})
|
|
172
|
-
recrel_assert_record_relations(rec3, expected={"relations": {}})
|
|
173
|
-
|
|
174
|
-
_test_create()
|
|
175
|
-
_test_delete()
|
|
176
|
-
# recreate for the next one, to have some more valuable test data
|
|
177
|
-
_test_create()
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
def _test_sibl_edition_relation(client, json_headers, testdata):
|
|
181
|
-
"""Test creation/deletion siblings edition relations."""
|
|
182
|
-
first_pid_value = "docid-3"
|
|
183
|
-
first_pid_type = "docid"
|
|
184
|
-
second_pid_value = "docid-1"
|
|
185
|
-
second_pid_type = "docid"
|
|
186
|
-
third_pid_value = "docid-8"
|
|
187
|
-
third_pid_type = "docid"
|
|
188
|
-
relation_type = "edition"
|
|
189
|
-
|
|
190
|
-
payload = [
|
|
191
|
-
{
|
|
192
|
-
"pid_value": second_pid_value,
|
|
193
|
-
"pid_type": second_pid_type,
|
|
194
|
-
"relation_type": relation_type,
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
"pid_value": third_pid_value,
|
|
198
|
-
"pid_type": third_pid_type,
|
|
199
|
-
"relation_type": relation_type,
|
|
200
|
-
},
|
|
201
|
-
]
|
|
202
|
-
|
|
203
|
-
def _test_create():
|
|
204
|
-
"""Test relation creation."""
|
|
205
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
206
|
-
(client, json_headers, "POST"),
|
|
207
|
-
(
|
|
208
|
-
first_pid_value,
|
|
209
|
-
first_pid_type,
|
|
210
|
-
second_pid_value,
|
|
211
|
-
second_pid_type,
|
|
212
|
-
),
|
|
213
|
-
payload,
|
|
214
|
-
)
|
|
215
|
-
rec3 = Document.get_record_by_pid(third_pid_value)
|
|
216
|
-
rec3 = rec3.replace_refs()
|
|
217
|
-
|
|
218
|
-
recrel_assert_record_relations(
|
|
219
|
-
rec1,
|
|
220
|
-
expected={
|
|
221
|
-
"relations": {
|
|
222
|
-
"edition": [
|
|
223
|
-
{
|
|
224
|
-
"pid_value": second_pid_value,
|
|
225
|
-
"pid_type": second_pid_type,
|
|
226
|
-
"relation_type": "edition",
|
|
227
|
-
"record_metadata": {
|
|
228
|
-
"title": rec2["title"],
|
|
229
|
-
"edition": rec2["edition"],
|
|
230
|
-
"languages": rec2["languages"],
|
|
231
|
-
"document_type": rec2["document_type"],
|
|
232
|
-
"publication_year": rec2["publication_year"],
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"pid_value": third_pid_value,
|
|
237
|
-
"pid_type": third_pid_type,
|
|
238
|
-
"relation_type": "edition",
|
|
239
|
-
"record_metadata": {
|
|
240
|
-
"title": rec3["title"],
|
|
241
|
-
"edition": rec3["edition"],
|
|
242
|
-
"document_type": rec3["document_type"],
|
|
243
|
-
"publication_year": rec3["publication_year"],
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
]
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
)
|
|
250
|
-
recrel_assert_record_relations(
|
|
251
|
-
rec3,
|
|
252
|
-
expected={
|
|
253
|
-
"relations": {
|
|
254
|
-
"edition": [
|
|
255
|
-
{
|
|
256
|
-
"pid_value": second_pid_value,
|
|
257
|
-
"pid_type": second_pid_type,
|
|
258
|
-
"relation_type": "edition",
|
|
259
|
-
"record_metadata": {
|
|
260
|
-
"title": rec2["title"],
|
|
261
|
-
"edition": rec2["edition"],
|
|
262
|
-
"languages": rec2["languages"],
|
|
263
|
-
"document_type": rec2["document_type"],
|
|
264
|
-
"publication_year": rec2["publication_year"],
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
"pid_value": first_pid_value,
|
|
269
|
-
"pid_type": first_pid_type,
|
|
270
|
-
"relation_type": "edition",
|
|
271
|
-
"record_metadata": {
|
|
272
|
-
"title": rec1["title"],
|
|
273
|
-
"edition": rec1["edition"],
|
|
274
|
-
"document_type": rec1["document_type"],
|
|
275
|
-
"publication_year": rec1["publication_year"],
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
]
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
rec_docid_2 = get_test_record(testdata, "documents", "docid-2")
|
|
284
|
-
rec_docid_6 = get_test_record(testdata, "documents", "docid-6")
|
|
285
|
-
|
|
286
|
-
recrel_assert_record_relations(
|
|
287
|
-
rec2,
|
|
288
|
-
{
|
|
289
|
-
"relations": {
|
|
290
|
-
"edition": [
|
|
291
|
-
{
|
|
292
|
-
"pid_value": third_pid_value,
|
|
293
|
-
"pid_type": third_pid_type,
|
|
294
|
-
"relation_type": "edition",
|
|
295
|
-
"record_metadata": {
|
|
296
|
-
"title": rec3["title"],
|
|
297
|
-
"edition": rec3["edition"],
|
|
298
|
-
"document_type": rec3["document_type"],
|
|
299
|
-
"publication_year": rec3["publication_year"],
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"pid_value": first_pid_value,
|
|
304
|
-
"pid_type": first_pid_type,
|
|
305
|
-
"relation_type": "edition",
|
|
306
|
-
"record_metadata": {
|
|
307
|
-
"title": rec1["title"],
|
|
308
|
-
"edition": rec1["edition"],
|
|
309
|
-
"document_type": rec1["document_type"],
|
|
310
|
-
"publication_year": rec1["publication_year"],
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
|
-
"language": [
|
|
315
|
-
{
|
|
316
|
-
"pid_value": rec_docid_2["pid"],
|
|
317
|
-
"pid_type": "docid",
|
|
318
|
-
"relation_type": "language",
|
|
319
|
-
"record_metadata": {
|
|
320
|
-
"title": rec_docid_2["title"],
|
|
321
|
-
"languages": rec_docid_2["languages"],
|
|
322
|
-
"document_type": rec_docid_2["document_type"],
|
|
323
|
-
"publication_year": rec_docid_2["publication_year"],
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
"pid_value": rec_docid_6["pid"],
|
|
328
|
-
"pid_type": "docid",
|
|
329
|
-
"relation_type": "language",
|
|
330
|
-
"record_metadata": {
|
|
331
|
-
"title": rec_docid_6["title"],
|
|
332
|
-
"document_type": rec_docid_6["document_type"],
|
|
333
|
-
"languages": rec_docid_6["languages"],
|
|
334
|
-
"publication_year": rec_docid_6["publication_year"],
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
],
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
)
|
|
341
|
-
|
|
342
|
-
def _test_delete():
|
|
343
|
-
"""Test relation deletion."""
|
|
344
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
345
|
-
(client, json_headers, "DELETE"),
|
|
346
|
-
(
|
|
347
|
-
first_pid_value,
|
|
348
|
-
first_pid_type,
|
|
349
|
-
second_pid_value,
|
|
350
|
-
second_pid_type,
|
|
351
|
-
),
|
|
352
|
-
payload,
|
|
353
|
-
)
|
|
354
|
-
rec3 = Document.get_record_by_pid(third_pid_value)
|
|
355
|
-
rec3 = rec3.replace_refs()
|
|
356
|
-
|
|
357
|
-
recrel_assert_record_relations(rec1, expected={"relations": {}})
|
|
358
|
-
recrel_assert_record_relations(rec3, expected={"relations": {}})
|
|
359
|
-
|
|
360
|
-
rec_docid_2 = get_test_record(testdata, "documents", "docid-2")
|
|
361
|
-
rec_docid_6 = get_test_record(testdata, "documents", "docid-6")
|
|
362
|
-
|
|
363
|
-
# docid-1 should still have the languages relation created in the previous test
|
|
364
|
-
recrel_assert_record_relations(
|
|
365
|
-
rec2,
|
|
366
|
-
expected={
|
|
367
|
-
"relations": {
|
|
368
|
-
"language": [
|
|
369
|
-
{
|
|
370
|
-
"pid_value": rec_docid_2["pid"],
|
|
371
|
-
"pid_type": "docid",
|
|
372
|
-
"relation_type": "language",
|
|
373
|
-
"record_metadata": {
|
|
374
|
-
"title": rec_docid_2["title"],
|
|
375
|
-
"languages": rec_docid_2["languages"],
|
|
376
|
-
"document_type": rec_docid_2["document_type"],
|
|
377
|
-
"publication_year": rec_docid_2["publication_year"],
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
"pid_value": rec_docid_6["pid"],
|
|
382
|
-
"pid_type": "docid",
|
|
383
|
-
"relation_type": "language",
|
|
384
|
-
"record_metadata": {
|
|
385
|
-
"title": rec_docid_6["title"],
|
|
386
|
-
"document_type": rec_docid_6["document_type"],
|
|
387
|
-
"languages": rec_docid_6["languages"],
|
|
388
|
-
"publication_year": rec_docid_6["publication_year"],
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
]
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
)
|
|
395
|
-
|
|
396
|
-
def _test_empty_edition_field():
|
|
397
|
-
edition_first_pid_value = "docid-11"
|
|
398
|
-
edition_first_pid_type = "docid"
|
|
399
|
-
edition_second_pid_value = "docid-12"
|
|
400
|
-
edition_second_pid_type = "docid"
|
|
401
|
-
|
|
402
|
-
create_payload = {
|
|
403
|
-
"pid_value": edition_second_pid_value,
|
|
404
|
-
"pid_type": edition_second_pid_type,
|
|
405
|
-
"relation_type": relation_type,
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
409
|
-
(client, json_headers, "POST"),
|
|
410
|
-
(
|
|
411
|
-
edition_first_pid_value,
|
|
412
|
-
edition_first_pid_type,
|
|
413
|
-
edition_second_pid_value,
|
|
414
|
-
edition_second_pid_type,
|
|
415
|
-
),
|
|
416
|
-
create_payload,
|
|
417
|
-
expect_status_code=400,
|
|
418
|
-
)
|
|
419
|
-
|
|
420
|
-
_test_create()
|
|
421
|
-
_test_delete()
|
|
422
|
-
# recreate for the next one, to have some more valuable test data
|
|
423
|
-
_test_create()
|
|
424
|
-
_test_empty_edition_field()
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
def _test_sibl_other_relation(client, json_headers, testdata):
|
|
428
|
-
"""Test creation/deletion siblings other relations."""
|
|
429
|
-
first_pid_value = "docid-2"
|
|
430
|
-
first_pid_type = "docid"
|
|
431
|
-
second_pid_value = "docid-3"
|
|
432
|
-
second_pid_type = "docid"
|
|
433
|
-
relation_type = "other"
|
|
434
|
-
|
|
435
|
-
payload = {
|
|
436
|
-
"pid_value": second_pid_value,
|
|
437
|
-
"pid_type": second_pid_type,
|
|
438
|
-
"relation_type": relation_type,
|
|
439
|
-
"note": "exercise",
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
def _test_create():
|
|
443
|
-
"""Test relation creation."""
|
|
444
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
445
|
-
(client, json_headers, "POST"),
|
|
446
|
-
(
|
|
447
|
-
first_pid_value,
|
|
448
|
-
first_pid_type,
|
|
449
|
-
second_pid_value,
|
|
450
|
-
second_pid_type,
|
|
451
|
-
),
|
|
452
|
-
payload,
|
|
453
|
-
)
|
|
454
|
-
|
|
455
|
-
rec_docid_1 = get_test_record(testdata, "documents", "docid-1")
|
|
456
|
-
rec_docid_6 = get_test_record(testdata, "documents", "docid-6")
|
|
457
|
-
rec_docid_8 = get_test_record(testdata, "documents", "docid-8")
|
|
458
|
-
|
|
459
|
-
recrel_assert_record_relations(
|
|
460
|
-
rec1,
|
|
461
|
-
expected={
|
|
462
|
-
"relations_extra_metadata": {
|
|
463
|
-
"other": [
|
|
464
|
-
{
|
|
465
|
-
"pid_value": second_pid_value,
|
|
466
|
-
"pid_type": second_pid_type,
|
|
467
|
-
"note": "exercise",
|
|
468
|
-
}
|
|
469
|
-
]
|
|
470
|
-
},
|
|
471
|
-
"relations": {
|
|
472
|
-
"language": [
|
|
473
|
-
{
|
|
474
|
-
"pid_value": rec_docid_1["pid"],
|
|
475
|
-
"pid_type": "docid",
|
|
476
|
-
"relation_type": "language",
|
|
477
|
-
"record_metadata": {
|
|
478
|
-
"title": rec_docid_1["title"],
|
|
479
|
-
"edition": rec_docid_1["edition"],
|
|
480
|
-
"languages": rec_docid_1["languages"],
|
|
481
|
-
"document_type": rec_docid_1["document_type"],
|
|
482
|
-
"publication_year": rec_docid_1["publication_year"],
|
|
483
|
-
},
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
"pid_value": rec_docid_6["pid"],
|
|
487
|
-
"pid_type": "docid",
|
|
488
|
-
"relation_type": "language",
|
|
489
|
-
"record_metadata": {
|
|
490
|
-
"title": rec_docid_6["title"],
|
|
491
|
-
"document_type": rec_docid_6["document_type"],
|
|
492
|
-
"languages": rec_docid_6["languages"],
|
|
493
|
-
"publication_year": rec_docid_6["publication_year"],
|
|
494
|
-
},
|
|
495
|
-
},
|
|
496
|
-
],
|
|
497
|
-
"other": [
|
|
498
|
-
{
|
|
499
|
-
"pid_value": second_pid_value,
|
|
500
|
-
"pid_type": second_pid_type,
|
|
501
|
-
"note": "exercise",
|
|
502
|
-
"relation_type": "other",
|
|
503
|
-
"record_metadata": {
|
|
504
|
-
"title": rec2["title"],
|
|
505
|
-
"edition": rec2["edition"],
|
|
506
|
-
"document_type": rec2["document_type"],
|
|
507
|
-
"publication_year": rec2["publication_year"],
|
|
508
|
-
},
|
|
509
|
-
}
|
|
510
|
-
],
|
|
511
|
-
},
|
|
512
|
-
},
|
|
513
|
-
)
|
|
514
|
-
recrel_assert_record_relations(
|
|
515
|
-
rec2,
|
|
516
|
-
expected={
|
|
517
|
-
"relations": {
|
|
518
|
-
"edition": [
|
|
519
|
-
{
|
|
520
|
-
"pid_value": rec_docid_1["pid"],
|
|
521
|
-
"pid_type": "docid",
|
|
522
|
-
"relation_type": "edition",
|
|
523
|
-
"record_metadata": {
|
|
524
|
-
"title": rec_docid_1["title"],
|
|
525
|
-
"edition": rec_docid_1["edition"],
|
|
526
|
-
"languages": rec_docid_1["languages"],
|
|
527
|
-
"document_type": rec_docid_1["document_type"],
|
|
528
|
-
"publication_year": rec_docid_1["publication_year"],
|
|
529
|
-
},
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
"pid_value": rec_docid_8["pid"],
|
|
533
|
-
"pid_type": "docid",
|
|
534
|
-
"relation_type": "edition",
|
|
535
|
-
"record_metadata": {
|
|
536
|
-
"title": rec_docid_8["title"],
|
|
537
|
-
"edition": rec_docid_8["edition"],
|
|
538
|
-
"document_type": rec_docid_8["document_type"],
|
|
539
|
-
"publication_year": rec_docid_8["publication_year"],
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
],
|
|
543
|
-
"other": [
|
|
544
|
-
{
|
|
545
|
-
"pid_value": first_pid_value,
|
|
546
|
-
"pid_type": first_pid_type,
|
|
547
|
-
"note": "exercise",
|
|
548
|
-
"relation_type": "other",
|
|
549
|
-
"record_metadata": {
|
|
550
|
-
"title": rec1["title"],
|
|
551
|
-
"languages": rec1["languages"],
|
|
552
|
-
"document_type": rec1["document_type"],
|
|
553
|
-
"publication_year": rec1["publication_year"],
|
|
554
|
-
},
|
|
555
|
-
}
|
|
556
|
-
],
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
)
|
|
560
|
-
|
|
561
|
-
def _test_delete():
|
|
562
|
-
"""Test relation deletion."""
|
|
563
|
-
rec1, rec2 = recrel_choose_endpoints_and_do_request(
|
|
564
|
-
(client, json_headers, "DELETE"),
|
|
565
|
-
(
|
|
566
|
-
first_pid_value,
|
|
567
|
-
first_pid_type,
|
|
568
|
-
second_pid_value,
|
|
569
|
-
second_pid_type,
|
|
570
|
-
),
|
|
571
|
-
payload,
|
|
572
|
-
)
|
|
573
|
-
|
|
574
|
-
rec_docid_1 = get_test_record(testdata, "documents", "docid-1")
|
|
575
|
-
rec_docid_6 = get_test_record(testdata, "documents", "docid-6")
|
|
576
|
-
rec_docid_8 = get_test_record(testdata, "documents", "docid-8")
|
|
577
|
-
|
|
578
|
-
recrel_assert_record_relations(
|
|
579
|
-
rec1,
|
|
580
|
-
expected={
|
|
581
|
-
"relations": {
|
|
582
|
-
"language": [
|
|
583
|
-
{
|
|
584
|
-
"pid_value": rec_docid_1["pid"],
|
|
585
|
-
"pid_type": "docid",
|
|
586
|
-
"relation_type": "language",
|
|
587
|
-
"record_metadata": {
|
|
588
|
-
"title": rec_docid_1["title"],
|
|
589
|
-
"edition": rec_docid_1["edition"],
|
|
590
|
-
"languages": rec_docid_1["languages"],
|
|
591
|
-
"document_type": rec_docid_1["document_type"],
|
|
592
|
-
"publication_year": rec_docid_1["publication_year"],
|
|
593
|
-
},
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
"pid_value": rec_docid_6["pid"],
|
|
597
|
-
"pid_type": "docid",
|
|
598
|
-
"relation_type": "language",
|
|
599
|
-
"record_metadata": {
|
|
600
|
-
"title": rec_docid_6["title"],
|
|
601
|
-
"document_type": rec_docid_6["document_type"],
|
|
602
|
-
"languages": rec_docid_6["languages"],
|
|
603
|
-
"publication_year": rec_docid_6["publication_year"],
|
|
604
|
-
},
|
|
605
|
-
},
|
|
606
|
-
]
|
|
607
|
-
}
|
|
608
|
-
},
|
|
609
|
-
)
|
|
610
|
-
recrel_assert_record_relations(
|
|
611
|
-
rec2,
|
|
612
|
-
expected={
|
|
613
|
-
"relations": {
|
|
614
|
-
"edition": [
|
|
615
|
-
{
|
|
616
|
-
"pid_value": rec_docid_1["pid"],
|
|
617
|
-
"pid_type": "docid",
|
|
618
|
-
"relation_type": "edition",
|
|
619
|
-
"record_metadata": {
|
|
620
|
-
"title": rec_docid_1["title"],
|
|
621
|
-
"edition": rec_docid_1["edition"],
|
|
622
|
-
"languages": rec_docid_1["languages"],
|
|
623
|
-
"document_type": rec_docid_1["document_type"],
|
|
624
|
-
"publication_year": rec_docid_1["publication_year"],
|
|
625
|
-
},
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
"pid_value": rec_docid_8["pid"],
|
|
629
|
-
"pid_type": "docid",
|
|
630
|
-
"relation_type": "edition",
|
|
631
|
-
"record_metadata": {
|
|
632
|
-
"title": rec_docid_8["title"],
|
|
633
|
-
"edition": rec_docid_8["edition"],
|
|
634
|
-
"document_type": rec_docid_8["document_type"],
|
|
635
|
-
"publication_year": rec_docid_8["publication_year"],
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
]
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
)
|
|
642
|
-
|
|
643
|
-
_test_create()
|
|
644
|
-
_test_delete()
|
|
645
|
-
# recreate for the next one, to have some more valuable test data
|
|
646
|
-
_test_create()
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
def _test_sibl_invalid_relations_should_fail(
|
|
650
|
-
client, json_headers, invalids, status_code=400
|
|
651
|
-
):
|
|
652
|
-
"""Test relation creation with invalid siblings should fail."""
|
|
653
|
-
api_endpoint_documents = "invenio_app_ils_relations.docid_relations"
|
|
654
|
-
api_endpoint_series = "invenio_app_ils_relations.serid_relations"
|
|
655
|
-
|
|
656
|
-
for invalid in invalids:
|
|
657
|
-
first_pid_value = invalid["first_pid_value"]
|
|
658
|
-
first_pid_type = invalid["first_pid_type"]
|
|
659
|
-
second_pid_value = invalid["second_pid_value"]
|
|
660
|
-
second_pid_type = invalid["second_pid_type"]
|
|
661
|
-
relation_type = invalid["relation_type"]
|
|
662
|
-
|
|
663
|
-
api_endpoint = (
|
|
664
|
-
api_endpoint_documents if first_pid_type == "docid" else api_endpoint_series
|
|
665
|
-
)
|
|
666
|
-
|
|
667
|
-
url = url_for(api_endpoint, pid_value=first_pid_value)
|
|
668
|
-
payload = {
|
|
669
|
-
"pid_value": second_pid_value,
|
|
670
|
-
"pid_type": second_pid_type,
|
|
671
|
-
"relation_type": relation_type,
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
res = client.post(url, headers=json_headers, data=json.dumps(payload))
|
|
675
|
-
assert res.status_code == status_code
|
|
676
|
-
if status_code == 400:
|
|
677
|
-
error = json.loads(res.data.decode("utf-8"))
|
|
678
|
-
assert "message" in error
|
|
679
|
-
assert first_pid_value in error["message"]
|
|
680
|
-
assert second_pid_value in error["message"]
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
def test_siblings_relations(client, json_headers, testdata, users):
|
|
684
|
-
"""Test siblings relations."""
|
|
685
|
-
|
|
686
|
-
# only one test method to speed up tests and avoid testdata recreation at
|
|
687
|
-
# each test. As drawback, testdata is not cleaned between each test, so
|
|
688
|
-
# do not change the order of execution of the following tests :)
|
|
689
|
-
|
|
690
|
-
_test_sibl_invalid_relations_should_fail(
|
|
691
|
-
client,
|
|
692
|
-
json_headers,
|
|
693
|
-
[
|
|
694
|
-
{
|
|
695
|
-
"first_pid_value": "docid-1",
|
|
696
|
-
"first_pid_type": "docid",
|
|
697
|
-
"second_pid_value": "docid-2",
|
|
698
|
-
"second_pid_type": "docid",
|
|
699
|
-
"relation_type": "language",
|
|
700
|
-
}
|
|
701
|
-
],
|
|
702
|
-
status_code=401,
|
|
703
|
-
)
|
|
704
|
-
|
|
705
|
-
user_login(client, "librarian", users)
|
|
706
|
-
|
|
707
|
-
# docid-1 --language--> docid-2 and docid-6
|
|
708
|
-
_test_sibl_language_relation(client, json_headers)
|
|
709
|
-
|
|
710
|
-
# docid-3 --edition--> docid-1 and docid-8
|
|
711
|
-
_test_sibl_edition_relation(client, json_headers, testdata)
|
|
712
|
-
|
|
713
|
-
# docid-2 --other--> docid-3
|
|
714
|
-
_test_sibl_other_relation(client, json_headers, testdata)
|
|
715
|
-
|
|
716
|
-
# test wrong relations
|
|
717
|
-
invalids = [
|
|
718
|
-
# different pid type
|
|
719
|
-
{
|
|
720
|
-
"first_pid_value": "docid-1",
|
|
721
|
-
"first_pid_type": "docid",
|
|
722
|
-
"second_pid_value": "serid-1",
|
|
723
|
-
"second_pid_type": "serid",
|
|
724
|
-
"relation_type": "language",
|
|
725
|
-
},
|
|
726
|
-
# invalid edition: document with serial
|
|
727
|
-
{
|
|
728
|
-
"first_pid_value": "serid-3",
|
|
729
|
-
"first_pid_type": "serid",
|
|
730
|
-
"second_pid_value": "docid-5",
|
|
731
|
-
"second_pid_type": "docid",
|
|
732
|
-
"relation_type": "edition",
|
|
733
|
-
},
|
|
734
|
-
# different pid type
|
|
735
|
-
{
|
|
736
|
-
"first_pid_value": "serid-1",
|
|
737
|
-
"first_pid_type": "serid",
|
|
738
|
-
"second_pid_value": "docid-1",
|
|
739
|
-
"second_pid_type": "docid",
|
|
740
|
-
"relation_type": "other",
|
|
741
|
-
},
|
|
742
|
-
# same record
|
|
743
|
-
{
|
|
744
|
-
"first_pid_value": "docid-6",
|
|
745
|
-
"first_pid_type": "docid",
|
|
746
|
-
"second_pid_value": "docid-6",
|
|
747
|
-
"second_pid_type": "docid",
|
|
748
|
-
"relation_type": "language",
|
|
749
|
-
},
|
|
750
|
-
]
|
|
751
|
-
_test_sibl_invalid_relations_should_fail(client, json_headers, invalids)
|