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,95 +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 Series permissions."""
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
- SERIES_PID = "serid-1"
18
- ITEM_ENDPOINT = "invenio_records_rest.serid_item"
19
- LIST_ENDPOINT = "invenio_records_rest.serid_list"
20
-
21
-
22
- def test_series_read_permissions(client, testdata, json_headers, users):
23
- """Test Series endpoints read permissions."""
24
- tests = [
25
- ("admin", _HTTP_OK),
26
- ("librarian", _HTTP_OK),
27
- ("patron1", _HTTP_OK),
28
- ("anonymous", _HTTP_OK),
29
- ]
30
-
31
- def _test_list(expected_status):
32
- """Test get list."""
33
- url = url_for(LIST_ENDPOINT)
34
- res = client.get(url, headers=json_headers)
35
- assert res.status_code in expected_status
36
-
37
- def _test_read(expected_status, pid):
38
- """Test record read."""
39
- url = url_for(ITEM_ENDPOINT, pid_value=pid)
40
- res = client.get(url, headers=json_headers)
41
- assert res.status_code in expected_status
42
-
43
- for username, expected_status in tests:
44
- user_login(client, username, users)
45
- _test_list(expected_status)
46
- _test_read(expected_status, SERIES_PID)
47
-
48
-
49
- def test_series_edit_permissions(client, testdata, json_headers, users):
50
- """Test series endpoints permissions."""
51
- dummy_series = dict(
52
- title="The Gulf: The Making of An American Sea",
53
- authors=["Einstein, Albert", "Stachel, John J et al."],
54
- mode_of_issuance="MULTIPART_MONOGRAPH",
55
- )
56
- tests = [
57
- ("admin", _HTTP_OK, dummy_series),
58
- ("librarian", _HTTP_OK, dummy_series),
59
- ("patron1", [403], dummy_series),
60
- ("anonymous", [401], dummy_series),
61
- ]
62
-
63
- def _test_create(expected_status, data):
64
- """Test record creation."""
65
- url = url_for(LIST_ENDPOINT)
66
- res = client.post(url, headers=json_headers, data=json.dumps(data))
67
- assert res.status_code in expected_status
68
-
69
- if res.status_code < 400:
70
- record = res.get_json()["metadata"]
71
- assert record
72
- return record["pid"]
73
-
74
- def _test_update(expected_status, data, pid):
75
- """Test record update."""
76
- pid_value = pid or SERIES_PID
77
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
78
- res = client.put(url, headers=json_headers, data=json.dumps(data))
79
- assert res.status_code in expected_status
80
- if res.status_code < 400:
81
- record = res.get_json()["metadata"]
82
- assert record
83
-
84
- def _test_delete(expected_status, pid):
85
- """Test record delete."""
86
- pid_value = pid or SERIES_PID
87
- url = url_for(ITEM_ENDPOINT, pid_value=pid_value)
88
- res = client.delete(url, headers=json_headers)
89
- assert res.status_code in expected_status
90
-
91
- for username, expected_status, data in tests:
92
- user_login(client, username, users)
93
- pid = _test_create(expected_status, data)
94
- _test_update(expected_status, data, pid)
95
- _test_delete(expected_status, pid)
@@ -1,189 +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 anonymization of users."""
9
-
10
- from copy import deepcopy
11
-
12
- import pytest
13
- from flask import url_for
14
- from invenio_accounts.models import User
15
- from invenio_circulation.api import Loan
16
- from invenio_circulation.proxies import current_circulation
17
- from invenio_db import db
18
- from invenio_oauthclient.models import RemoteAccount, UserIdentity
19
- from invenio_search import current_search
20
- from invenio_userprofiles.models import UserProfile
21
-
22
- from invenio_app_ils.acquisition.api import Order
23
- from invenio_app_ils.acquisition.search import OrderSearch
24
- from invenio_app_ils.circulation.search import (
25
- get_active_loans_by_patron_pid,
26
- get_loans_by_patron_pid,
27
- )
28
- from invenio_app_ils.document_requests.api import DocumentRequest
29
- from invenio_app_ils.document_requests.search import DocumentRequestSearch
30
- from invenio_app_ils.errors import AnonymizationActiveLoansError
31
- from invenio_app_ils.ill.api import BorrowingRequest
32
- from invenio_app_ils.ill.search import BorrowingRequestsSearch
33
- from invenio_app_ils.patrons.anonymization import anonymize_patron_data
34
- from invenio_app_ils.patrons.api import patron_exists
35
- from tests.helpers import user_login, user_logout
36
-
37
-
38
- def check_user_deleted(user_pid):
39
- """ Check if user was deleted from database. """
40
- with db.session.begin_nested():
41
- user_identity = UserIdentity.query.filter(
42
- UserIdentity.id_user == user_pid
43
- ).first()
44
-
45
- assert user_identity is None
46
-
47
- remote_account = RemoteAccount.query.filter(
48
- RemoteAccount.user_id == user_pid
49
- ).first()
50
- assert remote_account is None
51
-
52
- user_profile = UserProfile.query.filter(
53
- UserProfile.user_id == user_pid
54
- ).first()
55
- assert user_profile is None
56
-
57
- user = User.query.filter(User.id == user_pid).first()
58
- assert user is None
59
-
60
-
61
- def check_user_exists(user_pid):
62
- """ Check if user exists in database. """
63
- with db.session.begin_nested():
64
- assert patron_exists(user_pid)
65
-
66
-
67
- def check_user_activity(app, user_pid, client, json_headers):
68
- """ Check if there are records related to the user. """
69
- # wait ES refresh
70
- current_search.flush_and_refresh(index="*")
71
-
72
- AnonymousPatron = app.config["ILS_PATRON_ANONYMOUS_CLASS"]
73
- anonymous_patron_fields = AnonymousPatron().dumps_loader()
74
-
75
- loans = get_loans_by_patron_pid(user_pid).scan()
76
- for hit in loans:
77
- # test ES
78
- assert hit["patron"] == anonymous_patron_fields
79
- # test DB
80
- loan = Loan.get_record_by_pid(hit.pid)
81
- assert loan["patron"] == anonymous_patron_fields
82
- # test REST
83
- url = url_for("invenio_records_rest.loanid_item", pid_value=hit.pid)
84
- res = client.get(url, headers=json_headers)
85
- assert res.get_json()["metadata"]["patron"] == anonymous_patron_fields
86
-
87
- borrowing_requests = (
88
- BorrowingRequestsSearch().search_by_patron_pid(user_pid).scan()
89
- )
90
- for hit in borrowing_requests:
91
- # test ES
92
- assert hit["patron"] == anonymous_patron_fields
93
- # test DB
94
- borrowing_request = BorrowingRequest.get_record_by_pid(hit.pid)
95
- assert borrowing_request["patron"] == anonymous_patron_fields
96
- # test REST
97
- url = url_for("invenio_records_rest.illbid_item", pid_value=hit.pid)
98
- res = client.get(url, headers=json_headers)
99
- assert res.get_json()["metadata"]["patron"] == anonymous_patron_fields
100
-
101
- document_requests = (
102
- DocumentRequestSearch().search_by_patron_pid(user_pid).scan()
103
- )
104
- for hit in document_requests:
105
- # test ES
106
- assert hit["patron"] == anonymous_patron_fields
107
- # test DB
108
- document_request = DocumentRequest.get_record_by_pid(hit.pid)
109
- assert document_request["patron"] == anonymous_patron_fields
110
- # test REST
111
- url = url_for("invenio_records_rest.dreqid_item", pid_value=hit.pid)
112
- res = client.get(url, headers=json_headers)
113
- assert res.get_json()["metadata"]["patron"] == anonymous_patron_fields
114
-
115
- acquisitions = OrderSearch().search_by_patron_pid(user_pid).scan()
116
- for hit in acquisitions:
117
- # test ES
118
- assert hit["patron"] == anonymous_patron_fields
119
- # test DB
120
- acquisition = Order.get_record_by_pid(hit.pid)
121
- assert acquisition["patron"] == anonymous_patron_fields
122
- # test REST
123
- url = url_for("invenio_records_rest.acqoid_item", pid_value=hit.pid)
124
- res = client.get(url, headers=json_headers)
125
- assert res.get_json()["metadata"]["patron"] == anonymous_patron_fields
126
-
127
-
128
- def cancel_active_loans(patron_pid, client, users):
129
- """Cancel active loans of a patron."""
130
- user = user_login(client, "admin", users)
131
-
132
- active_loans = get_active_loans_by_patron_pid(patron_pid).scan()
133
-
134
- for hit in active_loans:
135
- loan = Loan.get_record_by_pid(hit.pid)
136
- params = deepcopy(loan)
137
- params.update(
138
- dict(
139
- cancel_reason="Loan cancelled to anonymize user.",
140
- transaction_user_pid=str(user.id),
141
- )
142
- )
143
- current_circulation.circulation.trigger(
144
- loan, **dict(params, trigger="cancel")
145
- )
146
-
147
- loan.commit()
148
- db.session.commit()
149
- current_circulation.loan_indexer().index(loan)
150
-
151
- current_search.flush_and_refresh(index="*")
152
-
153
-
154
- def test_anonymization(app, client, json_headers, users, testdata):
155
- """Test anonymization of a user."""
156
- # Anonymize patron
157
- patron_pid = users["patron3"].id
158
-
159
- check_user_exists(patron_pid)
160
- cancel_active_loans(patron_pid, client, users)
161
- anonymize_patron_data(patron_pid)
162
- check_user_deleted(patron_pid)
163
-
164
- user_login(client, "admin", users)
165
- check_user_activity(app, patron_pid, client, json_headers)
166
- user_logout(client)
167
-
168
- # Anonymize librarian
169
- librarian_pid = users["librarian"].id
170
-
171
- check_user_exists(librarian_pid)
172
- cancel_active_loans(librarian_pid, client, users)
173
- anonymize_patron_data(librarian_pid)
174
- check_user_deleted(librarian_pid)
175
-
176
- # Anonymize patron while logged in
177
- patron_pid = users["patron2"].id
178
- user_login(client, "patron2", users)
179
-
180
- check_user_exists(patron_pid)
181
- cancel_active_loans(patron_pid, client, users)
182
- anonymize_patron_data(patron_pid)
183
- check_user_deleted(patron_pid)
184
-
185
- # It should fail when anonymizing patron with active loans
186
- patron_pid = users["patron1"].id
187
- check_user_exists(patron_pid)
188
- with pytest.raises(AnonymizationActiveLoansError):
189
- assert anonymize_patron_data(patron_pid)
@@ -1,76 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2018-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 ILS APIs."""
9
-
10
- import pytest
11
- from flask import url_for
12
- from invenio_accounts.models import User
13
-
14
- from invenio_app_ils.documents.api import Document
15
- from invenio_app_ils.patrons.api import patron_exists
16
- from invenio_app_ils.proxies import current_app_ils
17
- from invenio_app_ils.records.api import IlsRecord
18
- from invenio_app_ils.series.api import Series
19
- from tests.helpers import get_test_record
20
-
21
-
22
- def test_apis(client, json_headers, testdata):
23
- """Test various APIs."""
24
-
25
- def test_patron_exists():
26
- """Test return True if item exists."""
27
- test_patron = User.query.all()[0]
28
- assert patron_exists(int(test_patron.id))
29
- assert patron_exists(str(test_patron.id))
30
-
31
- with pytest.raises(AssertionError):
32
- assert not patron_exists("not a number")
33
- assert not patron_exists("-1")
34
- assert not patron_exists("0")
35
-
36
- def test_get_record_by_pid():
37
- """Test get_record_by_pid."""
38
- tests = [("docid-1", Document), ("serid-1", Series)]
39
-
40
- for pid, cls in tests:
41
- record = cls.get_record_by_pid(pid)
42
-
43
- assert isinstance(record, cls)
44
- assert record["pid"] == pid
45
- assert record._pid_type == cls._pid_type
46
-
47
- def test_get_record_by_pid_and_pid_type():
48
- """Test get_record_by_pid with pid_type."""
49
- tests = [("docid-1", "docid", Document), ("serid-1", "serid", Series)]
50
-
51
- for pid, pid_type, expected_cls in tests:
52
- record = IlsRecord.get_record_by_pid(pid, pid_type=pid_type)
53
-
54
- assert isinstance(record, expected_cls)
55
- assert record["pid"] == pid
56
- assert record._pid_type == pid_type
57
-
58
- def test_get_default_location_pid():
59
- """Asset that the default location is the first created."""
60
- first = get_test_record(testdata, "locations", "locid-1")
61
- pid_value, _ = current_app_ils.get_default_location_pid
62
- assert pid_value == first["pid"]
63
-
64
- def test_no_etag():
65
- """Assert that the response headers do not contain ETag."""
66
- url = url_for("invenio_records_rest.docid_item", pid_value="docid-1")
67
- res = client.get(url, headers=json_headers)
68
- assert res.cache_control.no_cache
69
- assert res.get_etag() == (None, None)
70
- assert "Last-Modified" not in res.headers
71
-
72
- test_patron_exists()
73
- test_get_record_by_pid()
74
- test_get_record_by_pid_and_pid_type()
75
- test_get_default_location_pid()
76
- test_no_etag()
@@ -1,324 +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
- """Location closures tests."""
9
-
10
- import json
11
-
12
- import arrow
13
- from flask import url_for
14
-
15
- from invenio_app_ils.closures.api import find_next_open_date
16
- from invenio_app_ils.proxies import current_app_ils
17
- from tests.helpers import user_login
18
-
19
- _HTTP_OK = [200, 201, 204]
20
- _LOCATION_PID = "locid-1"
21
- _LOCATION_NAME = "Location name"
22
- _ITEM_ENDPOINT = "invenio_records_rest.locid_item"
23
- _LIST_ENDPOINT = "invenio_records_rest.locid_list"
24
- _WEEKDAYS = [
25
- "monday",
26
- "tuesday",
27
- "wednesday",
28
- "thursday",
29
- "friday",
30
- "saturday",
31
- "sunday",
32
- ]
33
- _DEFAULT_TIMES = [
34
- {"start_time": "08:00", "end_time": "12:00"},
35
- {"start_time": "13:00", "end_time": "18:00"},
36
- ]
37
-
38
-
39
- def _build_location_closures_data(closed_weekdays, exceptions):
40
- opening_weekdays = []
41
- for name in _WEEKDAYS:
42
- is_open = name not in closed_weekdays
43
- obj = {"weekday": name, "is_open": is_open}
44
- if is_open:
45
- obj["times"] = _DEFAULT_TIMES
46
- opening_weekdays.append(obj)
47
-
48
- opening_exceptions = []
49
- for start_date, end_date, is_open in exceptions:
50
- opening_exceptions.append(
51
- {
52
- "title": "%s - %s" % (start_date, end_date),
53
- "start_date": start_date,
54
- "end_date": end_date,
55
- "is_open": is_open,
56
- }
57
- )
58
-
59
- return {
60
- "opening_weekdays": opening_weekdays,
61
- "opening_exceptions": opening_exceptions,
62
- }
63
-
64
-
65
- def _date_from_string(date_string):
66
- return arrow.get(date_string).date()
67
-
68
-
69
- def test_location_permissions(client, testdata, json_headers, users):
70
- """Test location endpoints permissions."""
71
- dummy_location = dict(
72
- name=_LOCATION_NAME,
73
- opening_weekdays=[
74
- {"weekday": w, "is_open": True, "times": _DEFAULT_TIMES}
75
- for w in _WEEKDAYS
76
- ],
77
- opening_exceptions=[],
78
- )
79
- tests = [
80
- ("admin", _HTTP_OK, dummy_location),
81
- ("librarian", _HTTP_OK, dummy_location),
82
- ("patron1", [403], dummy_location),
83
- ("anonymous", [401], dummy_location),
84
- ]
85
- read_statuses = [200]
86
-
87
- def _test_list(expected_status):
88
- """Test get list."""
89
- url = url_for(_LIST_ENDPOINT)
90
- res = client.get(url, headers=json_headers)
91
- assert res.status_code in expected_status
92
-
93
- def _test_create(expected_status, data):
94
- """Test record creation."""
95
- url = url_for(_LIST_ENDPOINT)
96
- res = client.post(url, headers=json_headers, data=json.dumps(data))
97
- assert res.status_code in expected_status
98
-
99
- if res.status_code < 400:
100
- record = res.get_json()["metadata"]
101
- assert record["name"] == _LOCATION_NAME
102
- return record["pid"]
103
-
104
- def _test_update(expected_status, data, pid):
105
- """Test record update."""
106
- pid_value = pid or _LOCATION_PID
107
- url = url_for(_ITEM_ENDPOINT, pid_value=pid_value)
108
- res = client.put(url, headers=json_headers, data=json.dumps(data))
109
- assert res.status_code in expected_status
110
- if res.status_code < 400:
111
- record = res.get_json()["metadata"]
112
- assert record["name"] == _LOCATION_NAME
113
-
114
- def _test_read(expected_status, pid):
115
- """Test record read."""
116
- pid_value = pid or _LOCATION_PID
117
- url = url_for(_ITEM_ENDPOINT, pid_value=pid_value)
118
- res = client.get(url, headers=json_headers)
119
- assert res.status_code in expected_status
120
-
121
- def _test_delete(expected_status, pid):
122
- """Test record delete."""
123
- pid_value = pid or _LOCATION_PID
124
- url = url_for(_ITEM_ENDPOINT, pid_value=pid_value)
125
- res = client.delete(url, headers=json_headers)
126
- assert res.status_code in expected_status
127
-
128
- for username, expected_status, data in tests:
129
- user_login(client, username, users)
130
- _test_list(read_statuses)
131
- pid = _test_create(expected_status, data)
132
- _test_update(expected_status, data, pid)
133
- _test_read(read_statuses, pid)
134
- _test_delete(expected_status, pid)
135
-
136
-
137
- def test_location_validation(client, json_headers, users, testdata):
138
- def _test_update_location_closures(data, expected_code):
139
- url = url_for(
140
- "invenio_records_rest.locid_item", pid_value=_LOCATION_PID
141
- )
142
- res = client.get(url, headers=json_headers)
143
- assert res.status_code == 200
144
- metadata = res.get_json()["metadata"]
145
- metadata.update(data)
146
- res = client.put(url, headers=json_headers, data=json.dumps(metadata))
147
- assert res.status_code == expected_code
148
-
149
- def _test_update_weekdays(weekdays, expected_code):
150
- data = [
151
- {
152
- "weekday": name,
153
- "is_open": is_open,
154
- **({"times": _DEFAULT_TIMES} if is_open else {}),
155
- }
156
- for name, is_open in weekdays
157
- ]
158
- _test_update_location_closures(
159
- {"opening_weekdays": data, "opening_exceptions": []}, expected_code
160
- )
161
-
162
- def _test_update_times(times, expected_code):
163
- ref = "monday"
164
- times_data = [
165
- {"start_time": start, "end_time": end} for start, end in times
166
- ]
167
- data = [
168
- {
169
- "weekday": w,
170
- "is_open": w == ref,
171
- **({"times": times_data} if w == ref else {}),
172
- }
173
- for w in _WEEKDAYS
174
- ]
175
- _test_update_location_closures(
176
- {"opening_weekdays": data, "opening_exceptions": []}, expected_code
177
- )
178
-
179
- def _test_update_exceptions(closed_weekdays, exceptions, expected_code):
180
- _test_update_location_closures(
181
- _build_location_closures_data(closed_weekdays, exceptions),
182
- expected_code,
183
- )
184
-
185
- user_login(client, "librarian", users)
186
-
187
- # Weekdays
188
-
189
- _test_update_weekdays([[w, True] for w in _WEEKDAYS], 200)
190
- _test_update_weekdays([[w, True] for w in _WEEKDAYS[::-1]], 200)
191
- _test_update_weekdays([[w, False] for w in _WEEKDAYS], 400)
192
- _test_update_weekdays([[w, True] for w in _WEEKDAYS[:6]], 400)
193
- _test_update_weekdays([[w, True] for w in _WEEKDAYS[:6] + ["monday"]], 400)
194
- _test_update_weekdays([["foobar", True]], 400)
195
-
196
- # Hours
197
-
198
- _test_update_times([["08:00", "12:00"], ["13:00", "18:00"]], 200)
199
- _test_update_times([["13:00", "18:00"], ["08:00", "12:00"]], 200)
200
- _test_update_times([["08:00", "18:00"]], 200)
201
- _test_update_times([], 400)
202
- _test_update_times(
203
- [["08:00", "10:00"], ["11:00", "12:00"], ["13:00", "18:00"]], 400
204
- )
205
- _test_update_times([["8:00", "12:00"], ["13:00", "18:00"]], 400)
206
- _test_update_times([["08:00", "12:0"], ["13:00", "18:00"]], 400)
207
- _test_update_times([["08:00", ""], ["13:00", "18:00"]], 400)
208
- _test_update_times([["08:00", "12:00"], ["12:00", "18:00"]], 400)
209
- _test_update_times([["08:00", "12:00"], ["09:00", "11:00"]], 400)
210
-
211
- # Exceptions
212
-
213
- _test_update_exceptions(
214
- ["saturday", "sunday"],
215
- [
216
- ["2000-01-01", "2000-01-05", False],
217
- ["2000-01-07", "2000-01-09", True],
218
- ["2000-01-10", "2000-01-15", True],
219
- ],
220
- 200,
221
- )
222
-
223
- _test_update_exceptions(
224
- ["saturday", "sunday"],
225
- [
226
- ["2000-01-12", "2000-01-17", True],
227
- ["2000-01-07", "2000-01-11", False],
228
- ["2000-01-02", "2000-01-04", True],
229
- ],
230
- 200,
231
- )
232
-
233
- _test_update_exceptions(
234
- [],
235
- [
236
- ["2000-01-01", "2000-01-05", False],
237
- ["2000-01-04", "2000-01-08", False],
238
- ],
239
- 400,
240
- )
241
-
242
- _test_update_exceptions(
243
- [],
244
- [
245
- ["2000-01-01", "2000-01-05", False],
246
- ["2000-01-04", "2000-01-08", True],
247
- ],
248
- 400,
249
- )
250
-
251
- _test_update_exceptions(
252
- [],
253
- [
254
- ["2000-01-01", "2000-01-01", False],
255
- ["2000-01-01", "2000-01-01", False],
256
- ],
257
- 400,
258
- )
259
-
260
- _test_update_exceptions(
261
- [],
262
- [
263
- ["2000-01-02", "2000-01-01", True],
264
- ],
265
- 400,
266
- )
267
-
268
-
269
- def test_find_next_open_date(app, db, testdata):
270
- def _update_location_closures_data(closed_weekdays, exceptions):
271
- Location = current_app_ils.location_record_cls
272
- record = Location.get_record_by_pid(_LOCATION_PID)
273
-
274
- record.update(
275
- _build_location_closures_data(closed_weekdays, exceptions)
276
- )
277
- record.commit()
278
- db.session.commit()
279
- current_app_ils.location_indexer.index(record)
280
-
281
- return record
282
-
283
- def _test(start_date, expected_next_open_date):
284
- next_open = find_next_open_date(
285
- _LOCATION_PID, _date_from_string(start_date)
286
- )
287
- if expected_next_open_date:
288
- assert next_open == _date_from_string(expected_next_open_date)
289
- else:
290
- assert next_open is None
291
-
292
- """
293
- Mon. Tue. Wed. Thu. Fri. Sat. Sun.
294
- 27 28 29 30 31 -01 -02
295
- x03 x04 x05 06 07 -08 -09
296
- x10 x11 x12 x13 x14 x15 x16
297
- x17 x18 x19 x20 x21 x22 -23
298
- x24 25 26 x27 x28 o29 o30
299
- 31 01 02 03 04 -05 -06
300
- """
301
-
302
- closed_weekdays = ["saturday", "sunday"]
303
- exceptions = [
304
- ["2000-01-03", "2000-01-05", False], # Mon. - Wed.
305
- ["2000-01-09", "2000-01-22", False], # Sun. - Sat.
306
- ["2000-01-24", "2000-01-24", False], # Mon.
307
- ["2000-01-27", "2000-01-28", False], # Thu. - Fri.
308
- ["2000-01-29", "2000-01-30", True], # Sat. - Sun.
309
- ]
310
- _update_location_closures_data(closed_weekdays, exceptions)
311
-
312
- _test("2000-01-01", "2000-01-06")
313
- _test("2000-01-04", "2000-01-06")
314
- _test("2000-01-06", "2000-01-06")
315
- _test("2000-01-07", "2000-01-07")
316
-
317
- _test("2000-01-09", "2000-01-25")
318
- _test("2000-01-13", "2000-01-25")
319
-
320
- _test("2000-01-26", "2000-01-26")
321
- _test("2000-01-27", "2000-01-29")
322
- _test("2000-01-30", "2000-01-30")
323
-
324
- _test("2000-02-05", "2000-02-07")