invenio-app-ils 4.5.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.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/METADATA +56 -43
- {invenio_app_ils-4.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/RECORD +24 -112
- {invenio_app_ils-4.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/entry_points.txt +3 -0
- {invenio_app_ils-4.5.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.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/WHEEL +0 -0
- {invenio_app_ils-4.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {invenio_app_ils-4.5.0.dist-info → invenio_app_ils-5.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2018 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 accessibility of resource endpoints."""
|
|
9
|
-
|
|
10
|
-
import copy
|
|
11
|
-
import json
|
|
12
|
-
|
|
13
|
-
from flask import url_for
|
|
14
|
-
|
|
15
|
-
from tests.helpers import user_login, validate_response
|
|
16
|
-
|
|
17
|
-
_HTTP_OK = [200, 201, 204]
|
|
18
|
-
ITEM_PID = "itemid-1"
|
|
19
|
-
ITEM_ENDPOINT = "invenio_records_rest.pitmid_item"
|
|
20
|
-
LIST_ENDPOINT = "invenio_records_rest.pitmid_list"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def test_items_permissions(client, testdata, item_record, json_headers, users):
|
|
24
|
-
"""Test items endpoints permissions."""
|
|
25
|
-
dummy_item = copy.deepcopy(item_record)
|
|
26
|
-
tests = [
|
|
27
|
-
("admin", _HTTP_OK, dummy_item),
|
|
28
|
-
("librarian", _HTTP_OK, dummy_item),
|
|
29
|
-
("patron1", [403], dummy_item),
|
|
30
|
-
("anonymous", [401], dummy_item),
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
def _test_list(expected_status):
|
|
34
|
-
"""Test get list."""
|
|
35
|
-
url = url_for(LIST_ENDPOINT)
|
|
36
|
-
res = client.get(url, headers=json_headers)
|
|
37
|
-
assert res.status_code in expected_status
|
|
38
|
-
|
|
39
|
-
def _test_create(expected_status, data):
|
|
40
|
-
"""Test record creation."""
|
|
41
|
-
url = url_for(LIST_ENDPOINT)
|
|
42
|
-
res = client.post(url, headers=json_headers, data=json.dumps(data))
|
|
43
|
-
assert res.status_code in expected_status
|
|
44
|
-
|
|
45
|
-
if res.status_code < 400:
|
|
46
|
-
record = res.get_json()["metadata"]
|
|
47
|
-
return record["pid"]
|
|
48
|
-
|
|
49
|
-
def _test_update(expected_status, data, pid):
|
|
50
|
-
"""Test record update."""
|
|
51
|
-
pid_value = pid or ITEM_PID
|
|
52
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
53
|
-
res = client.put(url, headers=json_headers, data=json.dumps(data))
|
|
54
|
-
assert res.status_code in expected_status
|
|
55
|
-
if res.status_code < 400:
|
|
56
|
-
record = res.get_json()["metadata"]
|
|
57
|
-
|
|
58
|
-
def _test_read(expected_status, pid):
|
|
59
|
-
"""Test record read."""
|
|
60
|
-
pid_value = pid or ITEM_PID
|
|
61
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
62
|
-
res = client.get(url, headers=json_headers)
|
|
63
|
-
assert res.status_code in expected_status
|
|
64
|
-
|
|
65
|
-
def _test_delete(expected_status, pid):
|
|
66
|
-
"""Test record delete."""
|
|
67
|
-
pid_value = pid or ITEM_PID
|
|
68
|
-
url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
|
|
69
|
-
res = client.delete(url, headers=json_headers)
|
|
70
|
-
assert res.status_code in expected_status
|
|
71
|
-
|
|
72
|
-
for username, expected_status, data in tests:
|
|
73
|
-
user_login(client, username, users)
|
|
74
|
-
_test_list(expected_status)
|
|
75
|
-
pid = _test_create(expected_status, data)
|
|
76
|
-
_test_update(expected_status, data, pid)
|
|
77
|
-
_test_read(expected_status, pid)
|
|
78
|
-
_test_delete(expected_status, pid)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def test_item_circulation(client, json_headers, testdata, users):
|
|
82
|
-
"""Test item circulation filtering."""
|
|
83
|
-
|
|
84
|
-
tests = [
|
|
85
|
-
("patron1", "itemid-56", 403, False),
|
|
86
|
-
("patron2", "itemid-56", 403, True),
|
|
87
|
-
("patron1", "itemid-57", 403, True),
|
|
88
|
-
("patron2", "itemid-57", 403, False),
|
|
89
|
-
("librarian", "itemid-56", 200, False),
|
|
90
|
-
("admin", "itemid-57", 200, False),
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
for username, pid, expected_resp_code, filtered in tests:
|
|
94
|
-
user_login(client, username, users)
|
|
95
|
-
url = url_for("invenio_records_rest.pitmid_item", pid_value=pid)
|
|
96
|
-
res = validate_response(
|
|
97
|
-
client, "get", url, json_headers, None, expected_resp_code
|
|
98
|
-
)
|
|
99
|
-
if res.status_code < 400:
|
|
100
|
-
circulation = res.json["metadata"]["circulation"]
|
|
101
|
-
filter_keys = ["loan_pid", "patron_pid"]
|
|
102
|
-
if filtered:
|
|
103
|
-
for key in filter_keys:
|
|
104
|
-
assert key not in circulation
|
|
105
|
-
else:
|
|
106
|
-
for key in filter_keys:
|
|
107
|
-
assert key in circulation
|
|
@@ -1,115 +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
|
-
"""Records relations tests helpers."""
|
|
9
|
-
|
|
10
|
-
from __future__ import unicode_literals
|
|
11
|
-
|
|
12
|
-
import json
|
|
13
|
-
|
|
14
|
-
from flask import url_for
|
|
15
|
-
|
|
16
|
-
from invenio_app_ils.records_relations.api import RecordRelationsExtraMetadata
|
|
17
|
-
|
|
18
|
-
TYPES_ENDPOINTS = {
|
|
19
|
-
"relation": {
|
|
20
|
-
"docid": "invenio_app_ils_relations.docid_relations",
|
|
21
|
-
"serid": "invenio_app_ils_relations.serid_relations",
|
|
22
|
-
},
|
|
23
|
-
"get": {
|
|
24
|
-
"docid": "invenio_records_rest.docid_item",
|
|
25
|
-
"serid": "invenio_records_rest.serid_item",
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def recrel_fetch_record(client, json_headers, url):
|
|
31
|
-
"""Fetch a record."""
|
|
32
|
-
res = client.get(url_for(url[0], pid_value=url[1]), headers=json_headers)
|
|
33
|
-
assert res.status_code == 200
|
|
34
|
-
return json.loads(res.data.decode("utf-8"))["metadata"]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def recrel_assert_record_relations(record, expected):
|
|
38
|
-
"""Test extra metadata and `relations` field on parent record."""
|
|
39
|
-
extra_metadata_field_name = RecordRelationsExtraMetadata.field_name()
|
|
40
|
-
relations_metadata = record.get(extra_metadata_field_name, {})
|
|
41
|
-
expected_metadata = expected.get(extra_metadata_field_name, {})
|
|
42
|
-
|
|
43
|
-
relations = record.get("relations", {})
|
|
44
|
-
expected_relations = expected.get("relations", {})
|
|
45
|
-
|
|
46
|
-
assert relations_metadata.keys() == expected_metadata.keys()
|
|
47
|
-
for relation, records in relations_metadata.items():
|
|
48
|
-
assert len(records) == len(expected_metadata[relation])
|
|
49
|
-
for rec in records:
|
|
50
|
-
assert rec in expected_metadata[relation]
|
|
51
|
-
assert relations.keys() == expected_relations.keys()
|
|
52
|
-
for relation, records in relations.items():
|
|
53
|
-
assert len(records) == len(expected_relations[relation])
|
|
54
|
-
for rec in records:
|
|
55
|
-
assert rec in expected_relations[relation]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def recrel_do_request_for_valid_relation(
|
|
59
|
-
client, json_headers, payload, url, method="POST", expect_status_code=None
|
|
60
|
-
):
|
|
61
|
-
"""Create a new valid relation."""
|
|
62
|
-
func = client.delete if method == "DELETE" else client.post
|
|
63
|
-
res = func(
|
|
64
|
-
url_for(url[0], pid_value=url[1]),
|
|
65
|
-
headers=json_headers,
|
|
66
|
-
data=json.dumps(payload),
|
|
67
|
-
)
|
|
68
|
-
if expect_status_code is None:
|
|
69
|
-
expected_status_code = 200 if method == "DELETE" else 201
|
|
70
|
-
else:
|
|
71
|
-
expected_status_code = expect_status_code
|
|
72
|
-
assert res.status_code == expected_status_code
|
|
73
|
-
if res.status_code not in [200, 201]:
|
|
74
|
-
return
|
|
75
|
-
return json.loads(res.data.decode("utf-8"))["metadata"]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def recrel_choose_endpoints_and_do_request(
|
|
79
|
-
client_params,
|
|
80
|
-
relation,
|
|
81
|
-
payload,
|
|
82
|
-
create_using_pid1=True,
|
|
83
|
-
expect_status_code=None,
|
|
84
|
-
):
|
|
85
|
-
"""Choose which endpoint to use, create relation, return records."""
|
|
86
|
-
client, json_headers, method = client_params
|
|
87
|
-
pid1, pid1_type, pid2, pid2_type = relation
|
|
88
|
-
|
|
89
|
-
if create_using_pid1:
|
|
90
|
-
url_create_rel = (TYPES_ENDPOINTS["relation"][pid1_type], pid1)
|
|
91
|
-
url_other = (TYPES_ENDPOINTS["get"][pid2_type], pid2)
|
|
92
|
-
|
|
93
|
-
record1 = recrel_do_request_for_valid_relation(
|
|
94
|
-
client,
|
|
95
|
-
json_headers,
|
|
96
|
-
payload,
|
|
97
|
-
url_create_rel,
|
|
98
|
-
method=method,
|
|
99
|
-
expect_status_code=expect_status_code,
|
|
100
|
-
)
|
|
101
|
-
record2 = recrel_fetch_record(client, json_headers, url_other)
|
|
102
|
-
else:
|
|
103
|
-
url_create_rel = (TYPES_ENDPOINTS["relation"][pid2_type], pid2)
|
|
104
|
-
url_other = (TYPES_ENDPOINTS["get"][pid1_type], pid1)
|
|
105
|
-
|
|
106
|
-
record2 = recrel_do_request_for_valid_relation(
|
|
107
|
-
client,
|
|
108
|
-
json_headers,
|
|
109
|
-
payload,
|
|
110
|
-
url_create_rel,
|
|
111
|
-
method=method,
|
|
112
|
-
expect_status_code=expect_status_code,
|
|
113
|
-
)
|
|
114
|
-
record1 = recrel_fetch_record(client, json_headers, url_other)
|
|
115
|
-
return record1, record2
|