invenio-app-ils 1.0.0a54__py2.py3-none-any.whl → 6.1.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.
Files changed (331) hide show
  1. invenio_app_ils/__init__.py +2 -2
  2. invenio_app_ils/acquisition/api.py +3 -1
  3. invenio_app_ils/acquisition/config.py +10 -21
  4. invenio_app_ils/acquisition/jsonresolvers/order_order_lines.py +1 -0
  5. invenio_app_ils/acquisition/mappings/os-v1/acq_orders/order-v1.0.0.json +364 -0
  6. invenio_app_ils/acquisition/mappings/os-v2/__init__.py +0 -0
  7. invenio_app_ils/acquisition/mappings/os-v2/acq_orders/order-v1.0.0.json +364 -0
  8. invenio_app_ils/acquisition/mappings/v7/acq_orders/order-v1.0.0.json +14 -0
  9. invenio_app_ils/acquisition/search.py +5 -15
  10. invenio_app_ils/assets/semantic-ui/less/theme.config +103 -0
  11. invenio_app_ils/assets/semantic-ui/templates/.gitkeep +0 -0
  12. invenio_app_ils/circulation/api.py +153 -67
  13. invenio_app_ils/circulation/config.py +29 -25
  14. invenio_app_ils/circulation/indexer.py +14 -19
  15. invenio_app_ils/circulation/loaders/__init__.py +2 -0
  16. invenio_app_ils/circulation/loaders/schemas/json/loan_checkout.py +2 -3
  17. invenio_app_ils/circulation/loaders/schemas/json/loan_request.py +82 -16
  18. invenio_app_ils/circulation/loaders/schemas/json/loan_self_checkout.py +19 -0
  19. invenio_app_ils/circulation/notifications/api.py +23 -19
  20. invenio_app_ils/circulation/notifications/messages.py +6 -6
  21. invenio_app_ils/circulation/notifications/tasks.py +1 -2
  22. invenio_app_ils/circulation/receivers.py +2 -5
  23. invenio_app_ils/circulation/search.py +23 -22
  24. invenio_app_ils/circulation/serializers/__init__.py +2 -2
  25. invenio_app_ils/circulation/serializers/csv.py +1 -3
  26. invenio_app_ils/circulation/serializers/custom_fields.py +5 -9
  27. invenio_app_ils/circulation/serializers/json.py +2 -6
  28. invenio_app_ils/circulation/serializers/response.py +12 -12
  29. invenio_app_ils/circulation/stats/views.py +5 -15
  30. invenio_app_ils/circulation/tasks.py +2 -6
  31. invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/self_checkout.html +19 -0
  32. invenio_app_ils/circulation/templates/invenio_app_ils_circulation/notifications/update_dates.html +19 -0
  33. invenio_app_ils/circulation/utils.py +23 -17
  34. invenio_app_ils/circulation/views.py +103 -39
  35. invenio_app_ils/cli.py +220 -260
  36. invenio_app_ils/closures/api.py +72 -7
  37. invenio_app_ils/closures/serializers/__init__.py +16 -0
  38. invenio_app_ils/closures/serializers/response.py +35 -0
  39. invenio_app_ils/closures/serializers/schema.py +28 -0
  40. invenio_app_ils/closures/tasks.py +4 -11
  41. invenio_app_ils/closures/views.py +66 -0
  42. invenio_app_ils/config.py +207 -150
  43. invenio_app_ils/document_requests/api.py +6 -21
  44. invenio_app_ils/document_requests/loaders/__init__.py +4 -12
  45. invenio_app_ils/document_requests/mappings/{v6 → os-v1}/__init__.py +2 -2
  46. invenio_app_ils/document_requests/mappings/os-v1/document_requests/document_request-v1.0.0.json +196 -0
  47. invenio_app_ils/document_requests/mappings/os-v2/__init__.py +8 -0
  48. invenio_app_ils/document_requests/mappings/os-v2/document_requests/document_request-v1.0.0.json +196 -0
  49. invenio_app_ils/document_requests/notifications/api.py +2 -7
  50. invenio_app_ils/document_requests/notifications/messages.py +3 -7
  51. invenio_app_ils/document_requests/search.py +2 -6
  52. invenio_app_ils/document_requests/views.py +4 -10
  53. invenio_app_ils/documents/api.py +19 -25
  54. invenio_app_ils/documents/indexer.py +13 -20
  55. invenio_app_ils/documents/jsonresolvers/document_circulation.py +11 -33
  56. invenio_app_ils/documents/jsonresolvers/document_eitem.py +1 -0
  57. invenio_app_ils/documents/jsonresolvers/document_item.py +8 -9
  58. invenio_app_ils/documents/jsonresolvers/document_stock.py +7 -7
  59. invenio_app_ils/documents/loaders/jsonschemas/document.py +3 -14
  60. invenio_app_ils/documents/mappings/{v6 → os-v1}/__init__.py +1 -1
  61. invenio_app_ils/documents/mappings/os-v1/documents/document-v1.0.0.json +932 -0
  62. invenio_app_ils/documents/mappings/os-v1/documents/document-v2.0.0.json +1066 -0
  63. invenio_app_ils/documents/mappings/os-v2/__init__.py +8 -0
  64. invenio_app_ils/documents/mappings/os-v2/documents/document-v1.0.0.json +932 -0
  65. invenio_app_ils/documents/mappings/os-v2/documents/document-v2.0.0.json +1066 -0
  66. invenio_app_ils/documents/mappings/v7/documents/document-v1.0.0.json +102 -11
  67. invenio_app_ils/documents/mappings/v7/documents/document-v2.0.0.json +1066 -0
  68. invenio_app_ils/documents/schemas/documents/document-v2.0.0.json +732 -0
  69. invenio_app_ils/eitems/api.py +41 -7
  70. invenio_app_ils/eitems/loaders/jsonschemas/eitems.py +6 -6
  71. invenio_app_ils/eitems/mappings/{v6 → os-v1}/__init__.py +1 -1
  72. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v1.0.0.json +139 -0
  73. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v2.0.0.json +142 -0
  74. invenio_app_ils/eitems/mappings/os-v1/eitems/eitem-v3.0.0.json +179 -0
  75. invenio_app_ils/{series/mappings/v6 → eitems/mappings/os-v2}/__init__.py +1 -1
  76. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v1.0.0.json +139 -0
  77. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v2.0.0.json +142 -0
  78. invenio_app_ils/eitems/mappings/os-v2/eitems/eitem-v3.0.0.json +179 -0
  79. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v1.0.0.json +12 -2
  80. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v2.0.0.json +142 -0
  81. invenio_app_ils/eitems/mappings/v7/eitems/eitem-v3.0.0.json +179 -0
  82. invenio_app_ils/eitems/schemas/eitems/eitem-v2.0.0.json +120 -0
  83. invenio_app_ils/eitems/schemas/eitems/eitem-v3.0.0.json +120 -0
  84. invenio_app_ils/eitems/search.py +3 -9
  85. invenio_app_ils/errors.py +119 -6
  86. invenio_app_ils/ext.py +15 -18
  87. invenio_app_ils/facets.py +13 -15
  88. invenio_app_ils/files/receivers.py +1 -1
  89. invenio_app_ils/files/views.py +1 -2
  90. invenio_app_ils/ill/api.py +1 -2
  91. invenio_app_ils/ill/config.py +10 -16
  92. invenio_app_ils/ill/jsonresolvers/borrowing_request_document.py +2 -3
  93. invenio_app_ils/ill/jsonresolvers/borrowing_request_patron.py +1 -3
  94. invenio_app_ils/ill/jsonresolvers/borrowing_request_provider.py +1 -3
  95. invenio_app_ils/ill/loaders/__init__.py +3 -9
  96. invenio_app_ils/ill/loaders/jsonschemas/patron_loan_actions.py +1 -8
  97. invenio_app_ils/ill/loaders/jsonschemas/patron_loan_extension_actions.py +3 -8
  98. invenio_app_ils/ill/mappings/{v6 → os-v1}/__init__.py +1 -1
  99. invenio_app_ils/ill/mappings/os-v1/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
  100. invenio_app_ils/{acquisition/mappings/v6 → ill/mappings/os-v2}/__init__.py +1 -1
  101. invenio_app_ils/ill/mappings/os-v2/ill_borrowing_requests/borrowing_request-v1.0.0.json +254 -0
  102. invenio_app_ils/ill/mappings/v7/ill_borrowing_requests/borrowing_request-v1.0.0.json +14 -0
  103. invenio_app_ils/ill/notifications/api.py +1 -4
  104. invenio_app_ils/ill/search.py +3 -9
  105. invenio_app_ils/ill/serializers/__init__.py +1 -3
  106. invenio_app_ils/ill/views.py +2 -4
  107. invenio_app_ils/internal_locations/api.py +1 -4
  108. invenio_app_ils/internal_locations/mappings/{v6 → os-v1}/__init__.py +1 -1
  109. invenio_app_ils/internal_locations/mappings/os-v1/internal_locations/internal_location-v1.0.0.json +108 -0
  110. invenio_app_ils/internal_locations/mappings/os-v2/__init__.py +8 -0
  111. invenio_app_ils/internal_locations/mappings/os-v2/internal_locations/internal_location-v1.0.0.json +108 -0
  112. invenio_app_ils/internal_locations/search.py +1 -3
  113. invenio_app_ils/items/api.py +18 -15
  114. invenio_app_ils/items/indexer.py +1 -3
  115. invenio_app_ils/items/jsonresolvers/item_document.py +1 -1
  116. invenio_app_ils/items/jsonresolvers/item_internal_location.py +2 -6
  117. invenio_app_ils/items/loaders/jsonschemas/items.py +2 -0
  118. {tests/api/circulation → invenio_app_ils/items/mappings/os-v1}/__init__.py +1 -1
  119. invenio_app_ils/items/mappings/os-v1/items/item-v1.0.0.json +285 -0
  120. invenio_app_ils/items/mappings/os-v1/items/item-v2.0.0.json +326 -0
  121. {tests/api/ill → invenio_app_ils/items/mappings/os-v2}/__init__.py +1 -1
  122. invenio_app_ils/items/mappings/os-v2/items/item-v1.0.0.json +285 -0
  123. invenio_app_ils/items/mappings/os-v2/items/item-v2.0.0.json +326 -0
  124. invenio_app_ils/items/mappings/v7/items/item-v1.0.0.json +11 -0
  125. invenio_app_ils/items/mappings/v7/items/item-v2.0.0.json +326 -0
  126. invenio_app_ils/items/schemas/items/item-v1.0.0.json +22 -0
  127. invenio_app_ils/items/schemas/items/item-v2.0.0.json +172 -0
  128. invenio_app_ils/items/search.py +18 -11
  129. invenio_app_ils/items/serializers/item.py +7 -6
  130. invenio_app_ils/literature/api.py +1 -3
  131. invenio_app_ils/literature/search.py +3 -5
  132. invenio_app_ils/literature/serializers/csv.py +1 -3
  133. invenio_app_ils/literature/serializers/json.py +1 -3
  134. invenio_app_ils/locations/api.py +2 -4
  135. invenio_app_ils/locations/indexer.py +3 -9
  136. invenio_app_ils/locations/loaders/__init__.py +1 -3
  137. invenio_app_ils/locations/loaders/jsonschemas/location.py +4 -11
  138. invenio_app_ils/locations/mappings/{v6 → os-v1}/__init__.py +1 -1
  139. invenio_app_ils/locations/mappings/os-v1/locations/location-v1.0.0.json +90 -0
  140. invenio_app_ils/locations/mappings/os-v2/__init__.py +8 -0
  141. invenio_app_ils/locations/mappings/os-v2/locations/location-v1.0.0.json +90 -0
  142. invenio_app_ils/notifications/messages.py +4 -3
  143. invenio_app_ils/notifications/tasks.py +1 -3
  144. invenio_app_ils/notifications/views.py +2 -2
  145. invenio_app_ils/patrons/anonymization.py +53 -32
  146. invenio_app_ils/patrons/api.py +3 -5
  147. invenio_app_ils/patrons/cli.py +1 -2
  148. invenio_app_ils/patrons/indexer.py +4 -13
  149. invenio_app_ils/patrons/mappings/os-v1/__init__.py +8 -0
  150. invenio_app_ils/patrons/mappings/os-v1/patrons/patron-v1.0.0.json +42 -0
  151. invenio_app_ils/patrons/mappings/os-v2/__init__.py +8 -0
  152. invenio_app_ils/patrons/mappings/os-v2/patrons/patron-v1.0.0.json +42 -0
  153. invenio_app_ils/patrons/views.py +4 -14
  154. invenio_app_ils/permissions.py +93 -35
  155. invenio_app_ils/providers/api.py +2 -6
  156. invenio_app_ils/providers/config.py +11 -19
  157. invenio_app_ils/providers/indexer.py +2 -6
  158. invenio_app_ils/providers/mappings/{v6 → os-v1}/__init__.py +1 -1
  159. invenio_app_ils/providers/mappings/os-v1/providers/provider-v1.0.0.json +57 -0
  160. invenio_app_ils/providers/mappings/os-v2/__init__.py +8 -0
  161. invenio_app_ils/providers/mappings/os-v2/providers/provider-v1.0.0.json +57 -0
  162. invenio_app_ils/providers/mappings/v7/__init__.py +1 -1
  163. invenio_app_ils/providers/proxies.py +1 -3
  164. invenio_app_ils/records/api.py +3 -9
  165. invenio_app_ils/records/loaders/schemas/changed_by.py +1 -3
  166. invenio_app_ils/records/loaders/schemas/identifiers.py +23 -0
  167. invenio_app_ils/records/metadata_extensions.py +1 -4
  168. invenio_app_ils/records/permissions.py +8 -2
  169. invenio_app_ils/records/serializers/__init__.py +1 -4
  170. invenio_app_ils/records/views.py +4 -7
  171. invenio_app_ils/records_relations/api.py +11 -34
  172. invenio_app_ils/records_relations/indexer.py +1 -3
  173. invenio_app_ils/records_relations/retriever.py +14 -9
  174. invenio_app_ils/records_relations/views.py +16 -50
  175. invenio_app_ils/relations/api.py +17 -16
  176. invenio_app_ils/search_permissions.py +24 -24
  177. invenio_app_ils/series/api.py +10 -12
  178. invenio_app_ils/series/loaders/jsonschemas/series.py +3 -2
  179. invenio_app_ils/{items/mappings/v6 → series/mappings/os-v1}/__init__.py +1 -1
  180. invenio_app_ils/series/mappings/os-v1/series/series-v1.0.0.json +324 -0
  181. invenio_app_ils/series/mappings/os-v1/series/series-v2.0.0.json +396 -0
  182. {tests/api/acquisition → invenio_app_ils/series/mappings/os-v2}/__init__.py +1 -1
  183. invenio_app_ils/series/mappings/os-v2/series/series-v1.0.0.json +324 -0
  184. invenio_app_ils/series/mappings/os-v2/series/series-v2.0.0.json +396 -0
  185. invenio_app_ils/series/mappings/v7/series/series-v1.0.0.json +35 -3
  186. invenio_app_ils/series/mappings/v7/series/series-v2.0.0.json +396 -0
  187. invenio_app_ils/series/schemas/series/series-v2.0.0.json +354 -0
  188. invenio_app_ils/stats/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.json +60 -0
  189. invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/__init__.py +9 -0
  190. invenio_app_ils/stats/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.json +60 -0
  191. invenio_app_ils/stats/event_builders.py +73 -0
  192. invenio_app_ils/stats/file_download/os-v1/file-download-v1.json +72 -0
  193. invenio_app_ils/stats/file_download/os-v2/__init__.py +9 -0
  194. invenio_app_ils/stats/file_download/os-v2/file-download-v1.json +72 -0
  195. invenio_app_ils/stats/processors.py +30 -0
  196. invenio_app_ils/stats/templates/aggregations/__init__.py +8 -0
  197. invenio_app_ils/stats/templates/aggregations/ils_record_changes/__init__.py +8 -0
  198. invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/__init__.py +8 -0
  199. invenio_app_ils/stats/templates/aggregations/ils_record_changes/os-v2/aggr-ils-record-changes-v1.json +41 -0
  200. {tests → invenio_app_ils/stats/templates/events}/__init__.py +2 -2
  201. invenio_app_ils/stats/templates/events/ils_record_changes/__init__.py +8 -0
  202. invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/__init__.py +8 -0
  203. invenio_app_ils/stats/templates/events/ils_record_changes/os-v2/ils-record-changes-v1.json +41 -0
  204. invenio_app_ils/templates/logged_out.html +12 -0
  205. invenio_app_ils/views.py +18 -4
  206. invenio_app_ils/vocabularies/api.py +1 -1
  207. invenio_app_ils/vocabularies/cli.py +6 -18
  208. invenio_app_ils/vocabularies/data/acq_order_line_payment_modes.json +5 -0
  209. invenio_app_ils/vocabularies/data/identifier_schemes.json +5 -0
  210. invenio_app_ils/vocabularies/indexer.py +1 -4
  211. invenio_app_ils/vocabularies/jsonresolvers/licenses.py +2 -11
  212. invenio_app_ils/vocabularies/mappings/os-v1/__init__.py +8 -0
  213. invenio_app_ils/vocabularies/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +23 -0
  214. invenio_app_ils/vocabularies/mappings/os-v2/__init__.py +8 -0
  215. invenio_app_ils/vocabularies/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +23 -0
  216. invenio_app_ils/vocabularies/sources/base.py +1 -3
  217. invenio_app_ils/webpack.py +27 -0
  218. invenio_app_ils-6.1.0.dist-info/METADATA +627 -0
  219. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/RECORD +227 -249
  220. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/WHEEL +1 -1
  221. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/entry_points.txt +9 -5
  222. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info}/top_level.txt +0 -1
  223. invenio_app_ils/acquisition/mappings/v6/acq_orders/order-v1.0.0.json +0 -352
  224. invenio_app_ils/document_requests/mappings/v6/document_requests/document_request-v1.0.0.json +0 -199
  225. invenio_app_ils/documents/mappings/v6/documents/document-v1.0.0.json +0 -843
  226. invenio_app_ils/eitems/mappings/v6/eitems/eitem-v1.0.0.json +0 -131
  227. invenio_app_ils/ill/mappings/v6/ill_borrowing_requests/borrowing_request-v1.0.0.json +0 -242
  228. invenio_app_ils/internal_locations/mappings/v6/internal_locations/internal_location-v1.0.0.json +0 -110
  229. invenio_app_ils/items/mappings/v6/items/item-v1.0.0.json +0 -276
  230. invenio_app_ils/locations/mappings/v6/locations/location-v1.0.0.json +0 -92
  231. invenio_app_ils/notifications/admin.py +0 -57
  232. invenio_app_ils/patrons/mappings/v6/__init__.py +0 -8
  233. invenio_app_ils/patrons/mappings/v6/patrons/patron-v1.0.0.json +0 -44
  234. invenio_app_ils/providers/mappings/v6/providers/provider-v1.0.0.json +0 -59
  235. invenio_app_ils/series/mappings/v6/series/series-v1.0.0.json +0 -298
  236. invenio_app_ils/stats/aggregations/aggr_file_download/v6/aggr-file-download-v1.json +0 -59
  237. invenio_app_ils/stats/file_download/v6/file-download-v1.json +0 -74
  238. invenio_app_ils/version.py +0 -14
  239. invenio_app_ils/vocabularies/mappings/v6/__init__.py +0 -8
  240. invenio_app_ils/vocabularies/mappings/v6/vocabularies/vocabulary-v1.0.0.json +0 -25
  241. invenio_app_ils-1.0.0a54.dist-info/METADATA +0 -95
  242. tests/api/__init__.py +0 -8
  243. tests/api/acquisition/test_acq_orders_crud.py +0 -102
  244. tests/api/acquisition/test_acq_orders_permissions.py +0 -104
  245. tests/api/acquisition/test_acq_providers_permissions.py +0 -83
  246. tests/api/circulation/test_expired_loans.py +0 -88
  247. tests/api/circulation/test_loan_checkout.py +0 -216
  248. tests/api/circulation/test_loan_default_durations.py +0 -57
  249. tests/api/circulation/test_loan_document_resolver.py +0 -18
  250. tests/api/circulation/test_loan_extend.py +0 -132
  251. tests/api/circulation/test_loan_item_permissions.py +0 -139
  252. tests/api/circulation/test_loan_item_resolver.py +0 -26
  253. tests/api/circulation/test_loan_list_permissions.py +0 -104
  254. tests/api/circulation/test_loan_patron_resolver.py +0 -38
  255. tests/api/circulation/test_loan_request.py +0 -234
  256. tests/api/circulation/test_loan_update.py +0 -150
  257. tests/api/circulation/test_notifications.py +0 -229
  258. tests/api/conftest.py +0 -236
  259. tests/api/document_requests/__init__.py +0 -8
  260. tests/api/document_requests/test_document_requests.py +0 -131
  261. tests/api/document_requests/test_document_requests_permissions.py +0 -177
  262. tests/api/document_requests/test_notifications_filter.py +0 -36
  263. tests/api/ill/test_ill_brw_crud.py +0 -84
  264. tests/api/ill/test_ill_brw_reqs_patron_loan_create_action.py +0 -207
  265. tests/api/ill/test_ill_brw_reqs_patron_loan_extension_actions.py +0 -298
  266. tests/api/ill/test_ill_brw_reqs_permissions.py +0 -169
  267. tests/api/ill/test_ill_providers_permissions.py +0 -82
  268. tests/api/ils/__init__.py +0 -8
  269. tests/api/ils/documents/__init__.py +0 -8
  270. tests/api/ils/documents/test_document_crud.py +0 -57
  271. tests/api/ils/documents/test_document_permissions.py +0 -106
  272. tests/api/ils/documents/test_document_resolvers.py +0 -35
  273. tests/api/ils/eitems/__init__.py +0 -8
  274. tests/api/ils/eitems/test_eitems_crud.py +0 -41
  275. tests/api/ils/eitems/test_eitems_permissions.py +0 -84
  276. tests/api/ils/eitems/test_files.py +0 -172
  277. tests/api/ils/items/__init__.py +0 -8
  278. tests/api/ils/items/test_apis.py +0 -43
  279. tests/api/ils/items/test_items_crud.py +0 -60
  280. tests/api/ils/items/test_items_permissions.py +0 -107
  281. tests/api/ils/items/test_items_update.py +0 -47
  282. tests/api/ils/records_relations/__init__.py +0 -8
  283. tests/api/ils/records_relations/helpers.py +0 -115
  284. tests/api/ils/records_relations/test_records_relations_parentchild.py +0 -560
  285. tests/api/ils/records_relations/test_records_relations_sequence.py +0 -302
  286. tests/api/ils/records_relations/test_records_relations_siblings.py +0 -678
  287. tests/api/ils/series/__init__.py +0 -8
  288. tests/api/ils/series/test_series_permissions.py +0 -95
  289. tests/api/ils/test_anonymization.py +0 -189
  290. tests/api/ils/test_apis.py +0 -76
  291. tests/api/ils/test_closures.py +0 -324
  292. tests/api/ils/test_errors.py +0 -126
  293. tests/api/ils/test_facets.py +0 -84
  294. tests/api/ils/test_internal_locations.py +0 -96
  295. tests/api/ils/test_loaders.py +0 -55
  296. tests/api/ils/test_metadata_extensions.py +0 -205
  297. tests/api/ils/test_notifications.py +0 -183
  298. tests/api/ils/test_notifications_mails.py +0 -39
  299. tests/api/ils/test_notifications_permissions.py +0 -55
  300. tests/api/ils/test_patrons.py +0 -106
  301. tests/api/ils/test_record_delete.py +0 -46
  302. tests/api/ils/test_record_permissions.py +0 -135
  303. tests/api/ils/test_resolvers.py +0 -207
  304. tests/api/ils/test_stats.py +0 -160
  305. tests/api/ils/test_tasks.py +0 -211
  306. tests/api/ils/test_vocabularies.py +0 -35
  307. tests/conftest.py +0 -123
  308. tests/data/acq_orders.json +0 -89
  309. tests/data/acq_providers.json +0 -12
  310. tests/data/document_requests.json +0 -77
  311. tests/data/documents.json +0 -237
  312. tests/data/eitems.json +0 -66
  313. tests/data/ill_borrowing_requests.json +0 -77
  314. tests/data/ill_providers.json +0 -12
  315. tests/data/internal_locations.json +0 -22
  316. tests/data/items.json +0 -271
  317. tests/data/loans.json +0 -133
  318. tests/data/loans_most_loaned.json +0 -128
  319. tests/data/locations.json +0 -20
  320. tests/data/series.json +0 -33
  321. tests/helpers.py +0 -104
  322. tests/templates/notifications/title_body.html +0 -8
  323. tests/templates/notifications/title_body_html.html +0 -13
  324. tests/templates/notifications/title_body_html_ctx.html +0 -13
  325. tests/templates/notifications/title_only.html +0 -3
  326. tests/test_version.py +0 -17
  327. /tests/templates/notifications/blank.html → /invenio_app_ils/acquisition/mappings/os-v1/__init__.py +0 -0
  328. /invenio_app_ils/stats/aggregations/aggr_file_download/{v6 → os-v1}/__init__.py +0 -0
  329. /invenio_app_ils/stats/file_download/{v6 → os-v1}/__init__.py +0 -0
  330. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/AUTHORS.rst +0 -0
  331. {invenio_app_ils-1.0.0a54.dist-info → invenio_app_ils-6.1.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,298 +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 ILL borrowing requests actions."""
9
-
10
- import json
11
- from datetime import timedelta
12
-
13
- import arrow
14
- from flask import url_for
15
-
16
- from invenio_app_ils.ill.api import BORROWING_REQUEST_PID_TYPE
17
- from tests.helpers import user_login, user_logout
18
-
19
-
20
- def _create_on_loan_brwreq(
21
- patron_id, loan_start_date, loan_end_date, client, json_headers
22
- ):
23
- """Create a new ON_LOAN ILL borrowing request."""
24
-
25
- def _create_brwreq(patron_id):
26
- brwreq = dict(
27
- document_pid="docid-3",
28
- provider_pid="ill-provid-2",
29
- patron_pid=patron_id,
30
- status="REQUESTED",
31
- type="PHYSICAL_COPY",
32
- )
33
- url = url_for("invenio_records_rest.illbid_list")
34
- res = client.post(url, headers=json_headers, data=json.dumps(brwreq))
35
- assert res.status_code == 201
36
- brw_req = res.get_json()["metadata"]
37
- return brw_req["pid"]
38
-
39
- def _create_loan_action(pid):
40
- """Send request to create a new loan from the ILL."""
41
- data = dict(
42
- loan_start_date=loan_start_date,
43
- loan_end_date=loan_end_date,
44
- transaction_location_pid="locid-1",
45
- )
46
- url = url_for("invenio_app_ils_ill.illbid_create_loan", pid_value=pid)
47
- res = client.post(url, headers=json_headers, data=json.dumps(data))
48
- assert res.status_code == 200
49
- brw_req = res.get_json()["metadata"]
50
- assert brw_req["status"] == "ON_LOAN"
51
- return brw_req
52
-
53
- brwreq_pid = _create_brwreq(patron_id)
54
- return _create_loan_action(brwreq_pid)
55
-
56
-
57
- def _create_on_loan_brwreq_random_dates(patron_id, client, json_headers):
58
- """Create a new ON_LOAN ILL borrowing request with random start/end."""
59
- loan_start_date = arrow.utcnow()
60
- loan_end_date = loan_start_date + timedelta(days=15)
61
- brwreq = _create_on_loan_brwreq(
62
- patron_id,
63
- loan_start_date.date().isoformat(),
64
- loan_end_date.date().isoformat(),
65
- client,
66
- json_headers,
67
- )
68
- return brwreq, brwreq["pid"]
69
-
70
-
71
- def _create_on_loan_brwreq_with_pending_extension(
72
- patron_id, client, json_headers
73
- ):
74
- """Create a new ON_LOAN ILL borrowing request with pending extension."""
75
- today = arrow.utcnow().date().isoformat()
76
- brwreq, brwreq_pid = _create_on_loan_brwreq_random_dates(
77
- "1", client, json_headers
78
- )
79
- res = _request_extension_action(brwreq_pid, client, json_headers)
80
- assert res.status_code == 200
81
-
82
- brwreq = res.get_json()["metadata"]
83
- patron_loan = brwreq["patron_loan"]
84
-
85
- assert patron_loan["loan"]["state"] == "ITEM_ON_LOAN"
86
- assert "extension_count" not in patron_loan["loan"]
87
- assert patron_loan["extension"]["status"] == "PENDING"
88
- assert patron_loan["extension"]["request_date"] == today
89
-
90
- return brwreq, brwreq["pid"]
91
-
92
-
93
- def _request_extension_action(pid, client, json_headers):
94
- """Send HTTP request to request extension of ILL Borrowing Request."""
95
- url = url_for(
96
- "invenio_app_ils_ill.illbid_request_extension", pid_value=pid
97
- )
98
- return client.post(url, headers=json_headers, data=json.dumps({}))
99
-
100
-
101
- def _accept_extension_action(pid, data, client, json_headers):
102
- """Send HTTP request to accept extension of ILL Borrowing Request."""
103
- data["transaction_location_pid"] = "locid-1"
104
- url = url_for("invenio_app_ils_ill.illbid_accept_extension", pid_value=pid)
105
- return client.post(url, headers=json_headers, data=json.dumps(data))
106
-
107
-
108
- def _decline_extension_action(pid, _, client, json_headers):
109
- """Send HTTP request to decline extension of ILL Borrowing Request."""
110
- url = url_for(
111
- "invenio_app_ils_ill.illbid_decline_extension", pid_value=pid
112
- )
113
- return client.post(url, headers=json_headers, data=json.dumps({}))
114
-
115
-
116
- def test_brwreq_request_extension_only_owner(
117
- client, testdata, json_headers, users
118
- ):
119
- """Test that patron can request extension only for his own loan."""
120
- user_login(client, "librarian", users)
121
-
122
- brwreq, brwreq_pid = _create_on_loan_brwreq_random_dates(
123
- "1", client, json_headers
124
- )
125
-
126
- # anonymous, forbidden
127
- user_logout(client)
128
- res = _request_extension_action(brwreq_pid, client, json_headers)
129
- assert res.status_code == 401
130
-
131
- # patron2 is not the owner, forbidden
132
- user_login(client, "patron2", users)
133
- res = _request_extension_action(brwreq_pid, client, json_headers)
134
- assert res.status_code == 403
135
-
136
- # patron1 is the owner, success
137
- user_login(client, "patron1", users)
138
- res = _request_extension_action(brwreq_pid, client, json_headers)
139
- assert res.status_code == 200
140
- extension = res.get_json()["metadata"]["patron_loan"]["extension"]
141
- assert extension["status"] == "PENDING"
142
- assert extension["request_date"] == arrow.now().date().isoformat()
143
-
144
- # create a new one with patron2 owner, librarian can request extension
145
- user_login(client, "librarian", users)
146
- brwreq, brwreq_pid = _create_on_loan_brwreq_random_dates(
147
- "2", client, json_headers
148
- )
149
- res = _request_extension_action(brwreq_pid, client, json_headers)
150
- assert res.status_code == 200
151
- assert extension["status"] == "PENDING"
152
- assert extension["request_date"] == arrow.now().date().isoformat()
153
-
154
-
155
- def test_brwreq_accept_decline_extension_only_librarian(
156
- client, testdata, json_headers, users
157
- ):
158
- """Test that only librarian can accept or decline an extension."""
159
-
160
- tests = [_accept_extension_action, _decline_extension_action]
161
- for action in tests:
162
- user_login(client, "librarian", users)
163
-
164
- # create request
165
- brwreq, brwreq_pid = _create_on_loan_brwreq_with_pending_extension(
166
- "1", client, json_headers
167
- )
168
-
169
- loan_end_date = arrow.utcnow() + timedelta(days=15)
170
- data = dict(loan_end_date=loan_end_date.date().isoformat())
171
-
172
- # accept/decline
173
-
174
- # anonymous, forbidden
175
- user_logout(client)
176
- res = action(brwreq_pid, data, client, json_headers)
177
- assert res.status_code == 401
178
-
179
- # patron, forbidden
180
- user_login(client, "patron1", users)
181
- res = action(brwreq_pid, data, client, json_headers)
182
- assert res.status_code == 403
183
-
184
- # librarian, success
185
- user_login(client, "librarian", users)
186
- res = action(brwreq_pid, data, client, json_headers)
187
- assert res.status_code == 200
188
-
189
-
190
- def test_brwreq_request_extension_fails_on_wrong_status(
191
- client, testdata, json_headers, users
192
- ):
193
- user_login(client, "patron1", users)
194
- # demo data "illbid-1" is not ON_LOAN
195
- res = _request_extension_action("illbid-1", client, json_headers)
196
- assert res.status_code == 400
197
- # demo data "illbid-7" has already a pending request extension
198
- res = _request_extension_action("illbid-7", client, json_headers)
199
- assert res.status_code == 400
200
- # demo data "illbid-" has declined request extension
201
- res = _request_extension_action("illbid-8", client, json_headers)
202
- assert res.status_code == 400
203
-
204
-
205
- def test_brwreq_accept_decline_extension_should_fail_when_loan_not_active(
206
- client, testdata, json_headers, users
207
- ):
208
- """Test that accept or decline an extension fails on loan not active."""
209
-
210
- tests = [_accept_extension_action, _decline_extension_action]
211
- for action in tests:
212
- user_login(client, "librarian", users)
213
-
214
- # create request
215
- brwreq, brwreq_pid = _create_on_loan_brwreq_with_pending_extension(
216
- "1", client, json_headers
217
- )
218
-
219
- # check-in loan
220
- loan_pid = brwreq["patron_loan"]["pid"]
221
- url = url_for(
222
- "invenio_circulation_loan_actions.loanid_actions",
223
- pid_value=loan_pid,
224
- action="checkin",
225
- )
226
- item_pid = dict(type=BORROWING_REQUEST_PID_TYPE, value=brwreq["pid"])
227
- params = dict(
228
- document_pid=brwreq["document_pid"],
229
- item_pid=item_pid,
230
- patron_pid=brwreq["patron_pid"],
231
- transaction_location_pid="locid-1",
232
- transaction_user_pid="1",
233
- )
234
- res = client.post(url, headers=json_headers, data=json.dumps(params))
235
- assert res.status_code == 202
236
-
237
- # accept extension
238
- loan_end_date = arrow.utcnow() + timedelta(days=15)
239
- data = dict(loan_end_date=loan_end_date.date().isoformat())
240
-
241
- res = action(brwreq_pid, data, client, json_headers)
242
- assert res.status_code == 400
243
-
244
-
245
- def test_brwreq_accept_extension_success(
246
- client, testdata, json_headers, users
247
- ):
248
- """Test accept extension success."""
249
- user_login(client, "librarian", users)
250
-
251
- # create request
252
- brwreq, brwreq_pid = _create_on_loan_brwreq_with_pending_extension(
253
- "1", client, json_headers
254
- )
255
-
256
- loan_end_date = arrow.utcnow() + timedelta(days=15)
257
- end_date = loan_end_date.date().isoformat()
258
- data = dict(loan_end_date=end_date)
259
-
260
- user_login(client, "librarian", users)
261
- # accept extension
262
- res = _accept_extension_action(brwreq_pid, data, client, json_headers)
263
- assert res.status_code == 200
264
-
265
- patron_loan = res.get_json()["metadata"]["patron_loan"]
266
- assert patron_loan["loan"]["state"] == "ITEM_ON_LOAN"
267
- assert patron_loan["loan"]["extension_count"] == 1
268
- assert patron_loan["loan"]["end_date"] == end_date
269
- assert "status" not in patron_loan["extension"]
270
-
271
-
272
- def test_brwreq_decline_extension_success(
273
- client, testdata, json_headers, users
274
- ):
275
- """Test declone extension success."""
276
- user_login(client, "librarian", users)
277
-
278
- # create request
279
- brwreq, brwreq_pid = _create_on_loan_brwreq_with_pending_extension(
280
- "1", client, json_headers
281
- )
282
- end_date = brwreq["patron_loan"]["loan"]["end_date"]
283
-
284
- user_login(client, "librarian", users)
285
- # decline extension
286
- res = _decline_extension_action(brwreq_pid, dict(), client, json_headers)
287
- assert res.status_code == 200
288
-
289
- patron_loan = res.get_json()["metadata"]["patron_loan"]
290
- assert patron_loan["loan"]["state"] == "ITEM_ON_LOAN"
291
- assert "extension_count" not in patron_loan["loan"]
292
- assert patron_loan["loan"]["end_date"] == end_date
293
- assert patron_loan["extension"]["status"] == "DECLINED"
294
-
295
- # request again should now fail because it has been declined
296
- user_login(client, "patron1", users)
297
- res = _request_extension_action(brwreq_pid, client, json_headers)
298
- assert res.status_code == 400
@@ -1,169 +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 ILL borrowing requests."""
9
-
10
- import json
11
-
12
- from flask import url_for
13
- from invenio_search import current_search
14
-
15
- from tests.helpers import user_login
16
-
17
- _HTTP_OK = [200, 201, 204]
18
- BRWREQ_PID = "illbid-1"
19
- ITEM_ENDPOINT = "invenio_records_rest.illbid_item"
20
- LIST_ENDPOINT = "invenio_records_rest.illbid_list"
21
-
22
-
23
- def test_ill_brwreqs_list_permissions(client, testdata, json_headers, users):
24
- """Test borrowing requests list permissions."""
25
- patron1_brwreq = dict(
26
- status="PENDING",
27
- document_pid="docid-1",
28
- patron_pid="1",
29
- provider_pid="ill-provid-1",
30
- type="PHYSICAL_COPY",
31
- )
32
- patron2_brwreq = dict(
33
- status="PENDING",
34
- document_pid="docid-1",
35
- patron_pid="2",
36
- provider_pid="ill-provid-1",
37
- type="PHYSICAL_COPY",
38
- )
39
-
40
- def _test_list(expected_status, pids):
41
- """Test get list for given pids."""
42
- q = " OR ".join(["pid:{}".format(pid) for pid in pids])
43
- list_url = url_for(LIST_ENDPOINT, q=q)
44
- res = client.get(list_url, headers=json_headers)
45
- assert res.status_code in expected_status
46
- return res.get_json()
47
-
48
- # create records
49
- list_url = url_for(LIST_ENDPOINT)
50
- user_login(client, "admin", users)
51
- res = client.post(
52
- list_url, headers=json_headers, data=json.dumps(patron1_brwreq)
53
- )
54
- patron1_brwreq_pid = res.get_json()["metadata"]["pid"]
55
-
56
- res = client.post(
57
- list_url, headers=json_headers, data=json.dumps(patron2_brwreq)
58
- )
59
- patron2_brwreq_pid = res.get_json()["metadata"]["pid"]
60
- all_pids = [patron1_brwreq_pid, patron2_brwreq_pid]
61
- # wait for ES
62
- current_search.flush_and_refresh(index="ill_borrowing_requests")
63
-
64
- # test results
65
- tests = [
66
- ("admin", _HTTP_OK, all_pids),
67
- ("librarian", _HTTP_OK, all_pids),
68
- ("patron1", _HTTP_OK, [patron1_brwreq_pid]),
69
- ("patron2", _HTTP_OK, [patron2_brwreq_pid]),
70
- ]
71
- for username, expected_status, expected_pids in tests:
72
- user_login(client, username, users)
73
- results = _test_list(expected_status, all_pids)
74
- assert results["hits"]["total"] == len(expected_pids)
75
- found_pids = [
76
- hit["metadata"]["pid"] for hit in results["hits"]["hits"]
77
- ]
78
- assert set(expected_pids) == set(found_pids)
79
-
80
- # anonymous
81
- user_login(client, "anonymous", users)
82
- _test_list([401], [])
83
-
84
-
85
- def test_ill_brwreq_details_permissions(client, testdata, json_headers, users):
86
- """Test borrowing requests details permissions."""
87
- dummy_borrowing_request = dict(
88
- status="PENDING",
89
- document_pid="docid-1",
90
- patron_pid="1",
91
- provider_pid="ill-provid-1",
92
- type="PHYSICAL_COPY",
93
- )
94
-
95
- def _test_create(expected_status, data, user):
96
- """Test record creation."""
97
- url = url_for(LIST_ENDPOINT)
98
- res = client.post(url, headers=json_headers, data=json.dumps(data))
99
- assert res.status_code in expected_status
100
-
101
- if res.status_code < 400:
102
- brw_req = res.get_json()["metadata"]
103
- assert brw_req["status"] == "PENDING"
104
- expected_created_by = dict(type="user_id", value=str(user.id))
105
- assert brw_req["created_by"] == expected_created_by
106
- assert not brw_req.get("updated_by")
107
- return brw_req["pid"]
108
-
109
- def _test_update(expected_status, data, pid, user):
110
- """Test record update."""
111
- pid_value = pid or BRWREQ_PID
112
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
113
- res = client.put(url, headers=json_headers, data=json.dumps(data))
114
- assert res.status_code in expected_status
115
- if res.status_code < 400:
116
- expected_changed_by = dict(type="user_id", value=str(user.id))
117
- brw_req = res.get_json()["metadata"]
118
- assert brw_req["created_by"] == expected_changed_by
119
- assert brw_req["updated_by"] == expected_changed_by
120
-
121
- def _test_read(expected_status, pid):
122
- """Test record read."""
123
- pid_value = pid or BRWREQ_PID
124
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
125
- res = client.get(url, headers=json_headers)
126
- assert res.status_code in expected_status
127
-
128
- def _test_delete(expected_status, pid):
129
- """Test record delete."""
130
- url = url_for(ITEM_ENDPOINT, pid_value=pid)
131
- res = client.delete(url, headers=json_headers)
132
- assert res.status_code in expected_status
133
-
134
- # create/update
135
- tests = [
136
- ("anonymous", [401], dummy_borrowing_request),
137
- ("patron2", [403], dummy_borrowing_request),
138
- ("patron1", [403], dummy_borrowing_request),
139
- ("librarian", _HTTP_OK, dummy_borrowing_request),
140
- ("admin", _HTTP_OK, dummy_borrowing_request),
141
- ]
142
- for username, expected_status, data in tests:
143
- user = user_login(client, username, users)
144
- pid = _test_create(expected_status, data, user)
145
- _test_update(expected_status, data, pid, user)
146
-
147
- # get
148
- tests = [
149
- ("anonymous", [401]),
150
- ("patron2", [403]),
151
- ("patron1", _HTTP_OK),
152
- ("librarian", _HTTP_OK),
153
- ("admin", _HTTP_OK),
154
- ]
155
- for username, expected_status in tests:
156
- user_login(client, username, users)
157
- _test_read(expected_status, BRWREQ_PID)
158
-
159
- # delete
160
- tests = [
161
- ("anonymous", [401]),
162
- ("patron2", [403]),
163
- ("patron1", [403]),
164
- ("librarian", [403]),
165
- ("admin", _HTTP_OK),
166
- ]
167
- for username, expected_status in tests:
168
- user_login(client, username, users)
169
- _test_delete(expected_status, BRWREQ_PID)
@@ -1,82 +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 ILL providers."""
9
-
10
- import json
11
-
12
- from flask import url_for
13
-
14
- from tests.helpers import user_login
15
-
16
- _HTTP_OK = [200, 201, 204]
17
- PROVIDER_PID = "ill-provid-1"
18
- PROVIDER_NAME = "A library"
19
- PROVIDER_TYPE = "LIBRARY"
20
- ITEM_ENDPOINT = "invenio_records_rest.provid_item"
21
- LIST_ENDPOINT = "invenio_records_rest.provid_list"
22
-
23
-
24
- def test_ill_providers_permissions(client, testdata, json_headers, users):
25
- """Test providers endpoints permissions."""
26
- dummy_provider = dict(name=PROVIDER_NAME, type=PROVIDER_TYPE)
27
- tests = [
28
- ("admin", _HTTP_OK, dummy_provider),
29
- ("librarian", _HTTP_OK, dummy_provider),
30
- ("patron1", [403], dummy_provider),
31
- ("anonymous", [401], dummy_provider),
32
- ]
33
-
34
- def _test_list(expected_status):
35
- """Test get list."""
36
- url = url_for(LIST_ENDPOINT)
37
- res = client.get(url, headers=json_headers)
38
- assert res.status_code in expected_status
39
-
40
- def _test_create(expected_status, data):
41
- """Test record creation."""
42
- url = url_for(LIST_ENDPOINT)
43
- res = client.post(url, headers=json_headers, data=json.dumps(data))
44
- assert res.status_code in expected_status
45
-
46
- if res.status_code < 400:
47
- record = res.get_json()["metadata"]
48
- assert record["name"] == PROVIDER_NAME
49
- assert record["type"] == PROVIDER_TYPE
50
- return record["pid"]
51
-
52
- def _test_update(expected_status, data, pid):
53
- """Test record update."""
54
- pid_value = pid or PROVIDER_PID
55
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
56
- res = client.put(url, headers=json_headers, data=json.dumps(data))
57
- assert res.status_code in expected_status
58
- if res.status_code < 400:
59
- record = res.get_json()["metadata"]
60
- assert record["name"] == PROVIDER_NAME
61
-
62
- def _test_read(expected_status, pid):
63
- """Test record read."""
64
- pid_value = pid or PROVIDER_PID
65
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
66
- res = client.get(url, headers=json_headers)
67
- assert res.status_code in expected_status
68
-
69
- def _test_delete(expected_status, pid):
70
- """Test record delete."""
71
- pid_value = pid or PROVIDER_PID
72
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
73
- res = client.delete(url, headers=json_headers)
74
- assert res.status_code in expected_status
75
-
76
- for username, expected_status, data in tests:
77
- user_login(client, username, users)
78
- _test_list(expected_status)
79
- pid = _test_create(expected_status, data)
80
- _test_update(expected_status, data, pid)
81
- _test_read(expected_status, pid)
82
- _test_delete(expected_status, pid)
tests/api/ils/__init__.py DELETED
@@ -1,8 +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
- """ILS API Tests."""
@@ -1,8 +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
- """Document API Tests."""
@@ -1,57 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2020 CERN.
4
- #
5
- # Invenio-Circulation is free software; you can redistribute it and/or modify
6
- # it under the terms of the MIT License; see LICENSE file for more details.
7
-
8
- """Tests documents CRUD."""
9
-
10
- from invenio_app_ils.documents.api import Document
11
-
12
-
13
- def _assert_extra_fields(doc):
14
- """Test that extra fields are automatically added."""
15
- assert "$schema" in doc
16
- assert "circulation" in doc and "$ref" in doc["circulation"]
17
- assert "relations" in doc and "$ref" in doc["relations"]
18
- assert "eitems" in doc and "$ref" in doc["eitems"]
19
- assert "items" in doc and "$ref" in doc["items"]
20
- assert "stock" in doc and "$ref" in doc["stock"]
21
-
22
-
23
- def test_document_creation_refs(app):
24
- """Test creation of a document."""
25
- d = dict(
26
- pid="a1bc",
27
- created_by={"type": "script", "value": "demo"},
28
- title="Test title",
29
- authors=[dict(full_name="John Doe")],
30
- publication_year="2010",
31
- document_type="BOOK",
32
- )
33
- doc = Document.create(d)
34
-
35
- _assert_extra_fields(doc)
36
-
37
-
38
- def test_document_update_refs(app):
39
- """Test update of a document."""
40
- d = dict(
41
- pid="a1bc",
42
- title="Test title",
43
- created_by={"type": "script", "value": "demo"},
44
- authors=[dict(full_name="John Doe")],
45
- publication_year="2010",
46
- document_type="BOOK",
47
- )
48
- doc = Document.create(d)
49
- del doc["circulation"]
50
- del doc["relations"]
51
- del doc["eitems"]
52
- del doc["items"]
53
- del doc["stock"]
54
- doc.update(dict(title="Test title 2"))
55
-
56
- _assert_extra_fields(doc)
57
- assert doc["title"] == "Test title 2"