udata 9.1.2.dev30355__py2.py3-none-any.whl → 9.1.2.dev30382__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.

Potentially problematic release.


This version of udata might be problematic. Click here for more details.

Files changed (425) hide show
  1. tasks/__init__.py +109 -107
  2. tasks/helpers.py +18 -18
  3. udata/__init__.py +4 -4
  4. udata/admin/views.py +5 -5
  5. udata/api/__init__.py +135 -124
  6. udata/api/commands.py +45 -37
  7. udata/api/errors.py +5 -4
  8. udata/api/fields.py +23 -21
  9. udata/api/oauth2.py +55 -74
  10. udata/api/parsers.py +15 -15
  11. udata/api/signals.py +1 -1
  12. udata/api_fields.py +137 -89
  13. udata/app.py +56 -54
  14. udata/assets.py +5 -5
  15. udata/auth/__init__.py +37 -26
  16. udata/auth/forms.py +23 -15
  17. udata/auth/helpers.py +1 -1
  18. udata/auth/mails.py +3 -3
  19. udata/auth/password_validation.py +19 -15
  20. udata/auth/views.py +94 -68
  21. udata/commands/__init__.py +71 -69
  22. udata/commands/cache.py +7 -7
  23. udata/commands/db.py +201 -140
  24. udata/commands/dcat.py +36 -30
  25. udata/commands/fixtures.py +100 -84
  26. udata/commands/images.py +21 -20
  27. udata/commands/info.py +17 -20
  28. udata/commands/init.py +10 -10
  29. udata/commands/purge.py +12 -13
  30. udata/commands/serve.py +41 -29
  31. udata/commands/static.py +16 -18
  32. udata/commands/test.py +20 -20
  33. udata/commands/tests/fixtures.py +26 -24
  34. udata/commands/worker.py +31 -33
  35. udata/core/__init__.py +12 -12
  36. udata/core/activity/__init__.py +0 -1
  37. udata/core/activity/api.py +59 -49
  38. udata/core/activity/models.py +28 -26
  39. udata/core/activity/signals.py +1 -1
  40. udata/core/activity/tasks.py +16 -10
  41. udata/core/badges/api.py +6 -6
  42. udata/core/badges/commands.py +14 -13
  43. udata/core/badges/fields.py +8 -5
  44. udata/core/badges/forms.py +7 -4
  45. udata/core/badges/models.py +16 -31
  46. udata/core/badges/permissions.py +1 -3
  47. udata/core/badges/signals.py +2 -2
  48. udata/core/badges/tasks.py +3 -2
  49. udata/core/badges/tests/test_commands.py +10 -10
  50. udata/core/badges/tests/test_model.py +24 -31
  51. udata/core/contact_point/api.py +19 -18
  52. udata/core/contact_point/api_fields.py +21 -14
  53. udata/core/contact_point/factories.py +2 -2
  54. udata/core/contact_point/forms.py +7 -6
  55. udata/core/contact_point/models.py +3 -5
  56. udata/core/dataservices/api.py +26 -21
  57. udata/core/dataservices/factories.py +13 -11
  58. udata/core/dataservices/models.py +35 -40
  59. udata/core/dataservices/permissions.py +4 -4
  60. udata/core/dataservices/rdf.py +40 -17
  61. udata/core/dataservices/tasks.py +4 -3
  62. udata/core/dataset/actions.py +10 -10
  63. udata/core/dataset/activities.py +21 -23
  64. udata/core/dataset/api.py +321 -298
  65. udata/core/dataset/api_fields.py +443 -271
  66. udata/core/dataset/apiv2.py +305 -229
  67. udata/core/dataset/commands.py +38 -36
  68. udata/core/dataset/constants.py +61 -54
  69. udata/core/dataset/csv.py +70 -74
  70. udata/core/dataset/events.py +39 -32
  71. udata/core/dataset/exceptions.py +8 -4
  72. udata/core/dataset/factories.py +57 -65
  73. udata/core/dataset/forms.py +87 -63
  74. udata/core/dataset/models.py +336 -280
  75. udata/core/dataset/permissions.py +9 -6
  76. udata/core/dataset/preview.py +15 -17
  77. udata/core/dataset/rdf.py +156 -122
  78. udata/core/dataset/search.py +92 -77
  79. udata/core/dataset/signals.py +1 -1
  80. udata/core/dataset/tasks.py +63 -54
  81. udata/core/discussions/actions.py +5 -5
  82. udata/core/discussions/api.py +124 -120
  83. udata/core/discussions/factories.py +2 -2
  84. udata/core/discussions/forms.py +9 -7
  85. udata/core/discussions/metrics.py +1 -3
  86. udata/core/discussions/models.py +25 -24
  87. udata/core/discussions/notifications.py +18 -14
  88. udata/core/discussions/permissions.py +3 -3
  89. udata/core/discussions/signals.py +4 -4
  90. udata/core/discussions/tasks.py +24 -28
  91. udata/core/followers/api.py +32 -33
  92. udata/core/followers/models.py +9 -9
  93. udata/core/followers/signals.py +3 -3
  94. udata/core/jobs/actions.py +7 -7
  95. udata/core/jobs/api.py +99 -92
  96. udata/core/jobs/commands.py +48 -49
  97. udata/core/jobs/forms.py +11 -11
  98. udata/core/jobs/models.py +6 -6
  99. udata/core/metrics/__init__.py +2 -2
  100. udata/core/metrics/commands.py +34 -30
  101. udata/core/metrics/models.py +2 -4
  102. udata/core/metrics/signals.py +1 -1
  103. udata/core/metrics/tasks.py +3 -3
  104. udata/core/organization/activities.py +12 -15
  105. udata/core/organization/api.py +167 -174
  106. udata/core/organization/api_fields.py +183 -124
  107. udata/core/organization/apiv2.py +32 -32
  108. udata/core/organization/commands.py +20 -22
  109. udata/core/organization/constants.py +11 -11
  110. udata/core/organization/csv.py +17 -15
  111. udata/core/organization/factories.py +8 -11
  112. udata/core/organization/forms.py +32 -26
  113. udata/core/organization/metrics.py +2 -1
  114. udata/core/organization/models.py +87 -67
  115. udata/core/organization/notifications.py +18 -14
  116. udata/core/organization/permissions.py +10 -11
  117. udata/core/organization/rdf.py +14 -14
  118. udata/core/organization/search.py +30 -28
  119. udata/core/organization/signals.py +7 -7
  120. udata/core/organization/tasks.py +42 -61
  121. udata/core/owned.py +38 -27
  122. udata/core/post/api.py +82 -81
  123. udata/core/post/constants.py +8 -5
  124. udata/core/post/factories.py +4 -4
  125. udata/core/post/forms.py +13 -14
  126. udata/core/post/models.py +20 -22
  127. udata/core/post/tests/test_api.py +30 -32
  128. udata/core/reports/api.py +8 -7
  129. udata/core/reports/constants.py +1 -3
  130. udata/core/reports/models.py +10 -10
  131. udata/core/reuse/activities.py +15 -19
  132. udata/core/reuse/api.py +123 -126
  133. udata/core/reuse/api_fields.py +120 -85
  134. udata/core/reuse/apiv2.py +11 -10
  135. udata/core/reuse/constants.py +23 -23
  136. udata/core/reuse/csv.py +18 -18
  137. udata/core/reuse/factories.py +5 -9
  138. udata/core/reuse/forms.py +24 -21
  139. udata/core/reuse/models.py +55 -51
  140. udata/core/reuse/permissions.py +2 -2
  141. udata/core/reuse/search.py +49 -46
  142. udata/core/reuse/signals.py +1 -1
  143. udata/core/reuse/tasks.py +4 -5
  144. udata/core/site/api.py +47 -50
  145. udata/core/site/factories.py +2 -2
  146. udata/core/site/forms.py +4 -5
  147. udata/core/site/models.py +94 -63
  148. udata/core/site/rdf.py +14 -14
  149. udata/core/spam/api.py +16 -9
  150. udata/core/spam/constants.py +4 -4
  151. udata/core/spam/fields.py +13 -7
  152. udata/core/spam/models.py +27 -20
  153. udata/core/spam/signals.py +1 -1
  154. udata/core/spam/tests/test_spam.py +6 -5
  155. udata/core/spatial/api.py +72 -80
  156. udata/core/spatial/api_fields.py +73 -58
  157. udata/core/spatial/commands.py +67 -64
  158. udata/core/spatial/constants.py +3 -3
  159. udata/core/spatial/factories.py +37 -54
  160. udata/core/spatial/forms.py +27 -26
  161. udata/core/spatial/geoids.py +17 -17
  162. udata/core/spatial/models.py +43 -47
  163. udata/core/spatial/tasks.py +2 -1
  164. udata/core/spatial/tests/test_api.py +115 -130
  165. udata/core/spatial/tests/test_fields.py +74 -77
  166. udata/core/spatial/tests/test_geoid.py +22 -22
  167. udata/core/spatial/tests/test_models.py +5 -7
  168. udata/core/spatial/translations.py +16 -16
  169. udata/core/storages/__init__.py +16 -18
  170. udata/core/storages/api.py +66 -64
  171. udata/core/storages/tasks.py +7 -7
  172. udata/core/storages/utils.py +15 -15
  173. udata/core/storages/views.py +5 -6
  174. udata/core/tags/api.py +17 -14
  175. udata/core/tags/csv.py +4 -4
  176. udata/core/tags/models.py +8 -5
  177. udata/core/tags/tasks.py +11 -13
  178. udata/core/tags/views.py +4 -4
  179. udata/core/topic/api.py +84 -73
  180. udata/core/topic/apiv2.py +157 -127
  181. udata/core/topic/factories.py +3 -4
  182. udata/core/topic/forms.py +12 -14
  183. udata/core/topic/models.py +14 -19
  184. udata/core/topic/parsers.py +26 -26
  185. udata/core/user/activities.py +30 -29
  186. udata/core/user/api.py +151 -152
  187. udata/core/user/api_fields.py +132 -100
  188. udata/core/user/apiv2.py +7 -7
  189. udata/core/user/commands.py +38 -38
  190. udata/core/user/factories.py +8 -9
  191. udata/core/user/forms.py +14 -11
  192. udata/core/user/metrics.py +2 -2
  193. udata/core/user/models.py +68 -69
  194. udata/core/user/permissions.py +4 -5
  195. udata/core/user/rdf.py +7 -8
  196. udata/core/user/tasks.py +2 -2
  197. udata/core/user/tests/test_user_model.py +24 -16
  198. udata/db/tasks.py +2 -1
  199. udata/entrypoints.py +35 -31
  200. udata/errors.py +2 -1
  201. udata/event/values.py +6 -6
  202. udata/factories.py +2 -2
  203. udata/features/identicon/api.py +5 -6
  204. udata/features/identicon/backends.py +48 -55
  205. udata/features/identicon/tests/test_backends.py +4 -5
  206. udata/features/notifications/__init__.py +0 -1
  207. udata/features/notifications/actions.py +9 -9
  208. udata/features/notifications/api.py +17 -13
  209. udata/features/territories/__init__.py +12 -10
  210. udata/features/territories/api.py +14 -15
  211. udata/features/territories/models.py +23 -28
  212. udata/features/transfer/actions.py +8 -11
  213. udata/features/transfer/api.py +84 -77
  214. udata/features/transfer/factories.py +2 -1
  215. udata/features/transfer/models.py +11 -12
  216. udata/features/transfer/notifications.py +19 -15
  217. udata/features/transfer/permissions.py +5 -5
  218. udata/forms/__init__.py +5 -2
  219. udata/forms/fields.py +164 -172
  220. udata/forms/validators.py +19 -22
  221. udata/forms/widgets.py +9 -13
  222. udata/frontend/__init__.py +31 -26
  223. udata/frontend/csv.py +68 -58
  224. udata/frontend/markdown.py +40 -44
  225. udata/harvest/actions.py +89 -77
  226. udata/harvest/api.py +294 -238
  227. udata/harvest/backends/__init__.py +4 -4
  228. udata/harvest/backends/base.py +128 -111
  229. udata/harvest/backends/dcat.py +80 -66
  230. udata/harvest/commands.py +56 -60
  231. udata/harvest/csv.py +8 -8
  232. udata/harvest/exceptions.py +6 -3
  233. udata/harvest/filters.py +24 -23
  234. udata/harvest/forms.py +27 -28
  235. udata/harvest/models.py +88 -80
  236. udata/harvest/notifications.py +15 -10
  237. udata/harvest/signals.py +13 -13
  238. udata/harvest/tasks.py +11 -10
  239. udata/harvest/tests/factories.py +23 -24
  240. udata/harvest/tests/test_actions.py +136 -166
  241. udata/harvest/tests/test_api.py +220 -214
  242. udata/harvest/tests/test_base_backend.py +117 -112
  243. udata/harvest/tests/test_dcat_backend.py +380 -308
  244. udata/harvest/tests/test_filters.py +33 -22
  245. udata/harvest/tests/test_models.py +11 -14
  246. udata/harvest/tests/test_notifications.py +6 -7
  247. udata/harvest/tests/test_tasks.py +7 -6
  248. udata/i18n.py +237 -78
  249. udata/linkchecker/backends.py +5 -11
  250. udata/linkchecker/checker.py +23 -22
  251. udata/linkchecker/commands.py +4 -6
  252. udata/linkchecker/models.py +6 -6
  253. udata/linkchecker/tasks.py +18 -20
  254. udata/mail.py +21 -21
  255. udata/migrations/2020-07-24-remove-s-from-scope-oauth.py +9 -8
  256. udata/migrations/2020-08-24-add-fs-filename.py +9 -8
  257. udata/migrations/2020-09-28-update-reuses-datasets-metrics.py +5 -4
  258. udata/migrations/2020-10-16-migrate-ods-resources.py +9 -10
  259. udata/migrations/2021-04-08-update-schema-with-new-structure.py +8 -7
  260. udata/migrations/2021-05-27-fix-default-schema-name.py +7 -6
  261. udata/migrations/2021-07-05-remove-unused-badges.py +17 -15
  262. udata/migrations/2021-07-07-update-schema-for-community-resources.py +7 -6
  263. udata/migrations/2021-08-17-follow-integrity.py +5 -4
  264. udata/migrations/2021-08-17-harvest-integrity.py +13 -12
  265. udata/migrations/2021-08-17-oauth2client-integrity.py +5 -4
  266. udata/migrations/2021-08-17-transfer-integrity.py +5 -4
  267. udata/migrations/2021-08-17-users-integrity.py +9 -8
  268. udata/migrations/2021-12-14-reuse-topics.py +7 -6
  269. udata/migrations/2022-04-21-improve-extension-detection.py +8 -7
  270. udata/migrations/2022-09-22-clean-inactive-harvest-datasets.py +16 -14
  271. udata/migrations/2022-10-10-add-fs_uniquifier-to-user-model.py +6 -6
  272. udata/migrations/2022-10-10-migrate-harvest-extras.py +36 -26
  273. udata/migrations/2023-02-08-rename-internal-dates.py +46 -28
  274. udata/migrations/2024-01-29-fix-reuse-and-dataset-with-private-None.py +10 -8
  275. udata/migrations/2024-03-22-migrate-activity-kwargs-to-extras.py +6 -4
  276. udata/migrations/2024-06-11-fix-reuse-datasets-references.py +7 -6
  277. udata/migrations/__init__.py +123 -105
  278. udata/models/__init__.py +4 -4
  279. udata/mongo/__init__.py +13 -11
  280. udata/mongo/badges_field.py +3 -2
  281. udata/mongo/datetime_fields.py +13 -12
  282. udata/mongo/document.py +17 -16
  283. udata/mongo/engine.py +15 -16
  284. udata/mongo/errors.py +2 -1
  285. udata/mongo/extras_fields.py +30 -20
  286. udata/mongo/queryset.py +12 -12
  287. udata/mongo/slug_fields.py +38 -28
  288. udata/mongo/taglist_field.py +1 -2
  289. udata/mongo/url_field.py +5 -5
  290. udata/mongo/uuid_fields.py +4 -3
  291. udata/notifications/__init__.py +1 -1
  292. udata/notifications/mattermost.py +10 -9
  293. udata/rdf.py +167 -188
  294. udata/routing.py +40 -45
  295. udata/search/__init__.py +18 -19
  296. udata/search/adapter.py +17 -16
  297. udata/search/commands.py +44 -51
  298. udata/search/fields.py +13 -20
  299. udata/search/query.py +23 -18
  300. udata/search/result.py +9 -10
  301. udata/sentry.py +21 -19
  302. udata/settings.py +262 -198
  303. udata/sitemap.py +8 -6
  304. udata/static/chunks/{11.e9b9ca1f3e03d4020377.js → 11.52e531c19f8de80c00cf.js} +3 -3
  305. udata/static/chunks/{11.e9b9ca1f3e03d4020377.js.map → 11.52e531c19f8de80c00cf.js.map} +1 -1
  306. udata/static/chunks/{13.038c0d9aa0dfa0181c4b.js → 13.c3343a7f1070061c0e10.js} +2 -2
  307. udata/static/chunks/{13.038c0d9aa0dfa0181c4b.js.map → 13.c3343a7f1070061c0e10.js.map} +1 -1
  308. udata/static/chunks/{16.0baa2b64a74a2dcde25c.js → 16.8fa42440ad75ca172e6d.js} +2 -2
  309. udata/static/chunks/{16.0baa2b64a74a2dcde25c.js.map → 16.8fa42440ad75ca172e6d.js.map} +1 -1
  310. udata/static/chunks/{19.350a9f150b074b4ecefa.js → 19.9c6c8412729cd6d59cfa.js} +3 -3
  311. udata/static/chunks/{19.350a9f150b074b4ecefa.js.map → 19.9c6c8412729cd6d59cfa.js.map} +1 -1
  312. udata/static/chunks/{5.6ebbce2b9b3e696d3da5.js → 5.71d15c2e4f21feee2a9a.js} +3 -3
  313. udata/static/chunks/{5.6ebbce2b9b3e696d3da5.js.map → 5.71d15c2e4f21feee2a9a.js.map} +1 -1
  314. udata/static/chunks/{6.d8a5f7b017bcbd083641.js → 6.9139dc098b8ea640b890.js} +3 -3
  315. udata/static/chunks/{6.d8a5f7b017bcbd083641.js.map → 6.9139dc098b8ea640b890.js.map} +1 -1
  316. udata/static/common.js +1 -1
  317. udata/static/common.js.map +1 -1
  318. udata/storage/s3.py +20 -13
  319. udata/tags.py +4 -5
  320. udata/tasks.py +43 -42
  321. udata/tests/__init__.py +9 -6
  322. udata/tests/api/__init__.py +5 -6
  323. udata/tests/api/test_auth_api.py +395 -321
  324. udata/tests/api/test_base_api.py +31 -33
  325. udata/tests/api/test_contact_points.py +7 -9
  326. udata/tests/api/test_dataservices_api.py +211 -158
  327. udata/tests/api/test_datasets_api.py +823 -812
  328. udata/tests/api/test_follow_api.py +13 -15
  329. udata/tests/api/test_me_api.py +95 -112
  330. udata/tests/api/test_organizations_api.py +301 -339
  331. udata/tests/api/test_reports_api.py +35 -25
  332. udata/tests/api/test_reuses_api.py +134 -139
  333. udata/tests/api/test_swagger.py +5 -5
  334. udata/tests/api/test_tags_api.py +18 -25
  335. udata/tests/api/test_topics_api.py +94 -94
  336. udata/tests/api/test_transfer_api.py +53 -48
  337. udata/tests/api/test_user_api.py +128 -141
  338. udata/tests/apiv2/test_datasets.py +290 -198
  339. udata/tests/apiv2/test_me_api.py +10 -11
  340. udata/tests/apiv2/test_organizations.py +56 -74
  341. udata/tests/apiv2/test_swagger.py +5 -5
  342. udata/tests/apiv2/test_topics.py +69 -87
  343. udata/tests/cli/test_cli_base.py +8 -8
  344. udata/tests/cli/test_db_cli.py +21 -19
  345. udata/tests/dataservice/test_dataservice_tasks.py +8 -12
  346. udata/tests/dataset/test_csv_adapter.py +44 -35
  347. udata/tests/dataset/test_dataset_actions.py +2 -3
  348. udata/tests/dataset/test_dataset_commands.py +7 -8
  349. udata/tests/dataset/test_dataset_events.py +36 -29
  350. udata/tests/dataset/test_dataset_model.py +224 -217
  351. udata/tests/dataset/test_dataset_rdf.py +142 -131
  352. udata/tests/dataset/test_dataset_tasks.py +15 -15
  353. udata/tests/dataset/test_resource_preview.py +10 -13
  354. udata/tests/features/territories/__init__.py +9 -13
  355. udata/tests/features/territories/test_territories_api.py +71 -91
  356. udata/tests/forms/test_basic_fields.py +7 -7
  357. udata/tests/forms/test_current_user_field.py +39 -66
  358. udata/tests/forms/test_daterange_field.py +31 -39
  359. udata/tests/forms/test_dict_field.py +28 -26
  360. udata/tests/forms/test_extras_fields.py +102 -76
  361. udata/tests/forms/test_form_field.py +8 -8
  362. udata/tests/forms/test_image_field.py +33 -26
  363. udata/tests/forms/test_model_field.py +134 -123
  364. udata/tests/forms/test_model_list_field.py +7 -7
  365. udata/tests/forms/test_nested_model_list_field.py +117 -79
  366. udata/tests/forms/test_publish_as_field.py +36 -65
  367. udata/tests/forms/test_reference_field.py +34 -53
  368. udata/tests/forms/test_user_forms.py +23 -21
  369. udata/tests/forms/test_uuid_field.py +6 -10
  370. udata/tests/frontend/__init__.py +9 -6
  371. udata/tests/frontend/test_auth.py +7 -6
  372. udata/tests/frontend/test_csv.py +81 -96
  373. udata/tests/frontend/test_hooks.py +43 -43
  374. udata/tests/frontend/test_markdown.py +211 -191
  375. udata/tests/helpers.py +32 -37
  376. udata/tests/models.py +2 -2
  377. udata/tests/organization/test_csv_adapter.py +21 -16
  378. udata/tests/organization/test_notifications.py +11 -18
  379. udata/tests/organization/test_organization_model.py +13 -13
  380. udata/tests/organization/test_organization_rdf.py +29 -22
  381. udata/tests/organization/test_organization_tasks.py +16 -17
  382. udata/tests/plugin.py +76 -73
  383. udata/tests/reuse/test_reuse_model.py +21 -21
  384. udata/tests/reuse/test_reuse_task.py +11 -13
  385. udata/tests/search/__init__.py +11 -12
  386. udata/tests/search/test_adapter.py +60 -70
  387. udata/tests/search/test_query.py +16 -16
  388. udata/tests/search/test_results.py +10 -7
  389. udata/tests/site/test_site_api.py +11 -16
  390. udata/tests/site/test_site_metrics.py +20 -30
  391. udata/tests/site/test_site_model.py +4 -5
  392. udata/tests/site/test_site_rdf.py +94 -78
  393. udata/tests/test_activity.py +17 -17
  394. udata/tests/test_discussions.py +292 -299
  395. udata/tests/test_i18n.py +37 -40
  396. udata/tests/test_linkchecker.py +91 -85
  397. udata/tests/test_mail.py +13 -17
  398. udata/tests/test_migrations.py +219 -180
  399. udata/tests/test_model.py +164 -157
  400. udata/tests/test_notifications.py +17 -17
  401. udata/tests/test_owned.py +14 -14
  402. udata/tests/test_rdf.py +25 -23
  403. udata/tests/test_routing.py +89 -93
  404. udata/tests/test_storages.py +137 -128
  405. udata/tests/test_tags.py +44 -46
  406. udata/tests/test_topics.py +7 -7
  407. udata/tests/test_transfer.py +42 -49
  408. udata/tests/test_uris.py +160 -161
  409. udata/tests/test_utils.py +79 -71
  410. udata/tests/user/test_user_rdf.py +5 -9
  411. udata/tests/workers/test_jobs_commands.py +57 -58
  412. udata/tests/workers/test_tasks_routing.py +23 -29
  413. udata/tests/workers/test_workers_api.py +125 -131
  414. udata/tests/workers/test_workers_helpers.py +6 -6
  415. udata/tracking.py +4 -6
  416. udata/uris.py +45 -46
  417. udata/utils.py +68 -66
  418. udata/wsgi.py +1 -1
  419. {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30382.dist-info}/METADATA +3 -2
  420. udata-9.1.2.dev30382.dist-info/RECORD +704 -0
  421. udata-9.1.2.dev30355.dist-info/RECORD +0 -704
  422. {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30382.dist-info}/LICENSE +0 -0
  423. {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30382.dist-info}/WHEEL +0 -0
  424. {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30382.dist-info}/entry_points.txt +0 -0
  425. {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30382.dist-info}/top_level.txt +0 -0
@@ -1,26 +1,27 @@
1
- import pytest
2
-
3
1
  from datetime import datetime
4
2
 
3
+ import pytest
5
4
  from flask import url_for
6
5
 
7
6
  from udata.core.badges.factories import badge_factory
8
7
  from udata.core.dataset.factories import DatasetFactory
9
- from udata.core.user.factories import AdminFactory
10
- from udata.core.reuse.factories import ReuseFactory
11
8
  from udata.core.organization.factories import OrganizationFactory
12
- from udata.core.user.factories import UserFactory
13
- from udata.models import Reuse, Follow, Member
14
9
  from udata.core.reuse.constants import REUSE_TOPICS, REUSE_TYPES
15
- from udata.utils import faker
16
-
10
+ from udata.core.reuse.factories import ReuseFactory
11
+ from udata.core.user.factories import AdminFactory, UserFactory
12
+ from udata.models import Follow, Member, Reuse
17
13
  from udata.tests.helpers import (
18
- assert200, assert201, assert204, assert400, assert404, assert410
14
+ assert200,
15
+ assert201,
16
+ assert204,
17
+ assert400,
18
+ assert404,
19
+ assert410,
19
20
  )
20
-
21
+ from udata.utils import faker
21
22
 
22
23
  pytestmark = [
23
- pytest.mark.usefixtures('clean_db'),
24
+ pytest.mark.usefixtures("clean_db"),
24
25
  ]
25
26
 
26
27
 
@@ -28,93 +29,93 @@ class ReuseAPITest:
28
29
  modules = []
29
30
 
30
31
  def test_reuse_api_list(self, api):
31
- '''It should fetch a reuse list from the API'''
32
+ """It should fetch a reuse list from the API"""
32
33
  reuses = ReuseFactory.create_batch(3, visible=True)
33
34
 
34
- response = api.get(url_for('api.reuses'))
35
+ response = api.get(url_for("api.reuses"))
35
36
  assert200(response)
36
- assert len(response.json['data']) == len(reuses)
37
+ assert len(response.json["data"]) == len(reuses)
37
38
 
38
39
  def test_reuse_api_list_with_filters(self, api):
39
- '''Should filters reuses results based on query filters'''
40
+ """Should filters reuses results based on query filters"""
40
41
  owner = UserFactory()
41
42
  org = OrganizationFactory()
42
43
 
43
- [ReuseFactory(topic='health', type='api') for i in range(2)]
44
+ [ReuseFactory(topic="health", type="api") for i in range(2)]
44
45
 
45
- tag_reuse = ReuseFactory(tags=['my-tag', 'other'], topic='health', type='api')
46
- owner_reuse = ReuseFactory(owner=owner, topic='health', type='api')
47
- org_reuse = ReuseFactory(organization=org, topic='health', type='api')
48
- featured_reuse = ReuseFactory(featured=True, topic='health', type='api')
49
- topic_reuse = ReuseFactory(topic='transport_and_mobility', type='api')
50
- type_reuse = ReuseFactory(topic='health', type='application')
46
+ tag_reuse = ReuseFactory(tags=["my-tag", "other"], topic="health", type="api")
47
+ owner_reuse = ReuseFactory(owner=owner, topic="health", type="api")
48
+ org_reuse = ReuseFactory(organization=org, topic="health", type="api")
49
+ featured_reuse = ReuseFactory(featured=True, topic="health", type="api")
50
+ topic_reuse = ReuseFactory(topic="transport_and_mobility", type="api")
51
+ type_reuse = ReuseFactory(topic="health", type="application")
51
52
 
52
53
  # filter on tag
53
- response = api.get(url_for('api.reuses', tag='my-tag'))
54
+ response = api.get(url_for("api.reuses", tag="my-tag"))
54
55
  assert200(response)
55
- assert len(response.json['data']) == 1
56
- assert response.json['data'][0]['id'] == str(tag_reuse.id)
56
+ assert len(response.json["data"]) == 1
57
+ assert response.json["data"][0]["id"] == str(tag_reuse.id)
57
58
 
58
59
  # filter on featured
59
- response = api.get(url_for('api.reuses', featured='true'))
60
+ response = api.get(url_for("api.reuses", featured="true"))
60
61
  assert200(response)
61
- assert len(response.json['data']) == 1
62
- assert response.json['data'][0]['id'] == str(featured_reuse.id)
62
+ assert len(response.json["data"]) == 1
63
+ assert response.json["data"][0]["id"] == str(featured_reuse.id)
63
64
 
64
65
  # filter on topic
65
- response = api.get(url_for('api.reuses', topic=topic_reuse.topic))
66
+ response = api.get(url_for("api.reuses", topic=topic_reuse.topic))
66
67
  assert200(response)
67
- assert len(response.json['data']) == 1
68
- assert response.json['data'][0]['id'] == str(topic_reuse.id)
68
+ assert len(response.json["data"]) == 1
69
+ assert response.json["data"][0]["id"] == str(topic_reuse.id)
69
70
 
70
71
  # filter on type
71
- response = api.get(url_for('api.reuses', type=type_reuse.type))
72
+ response = api.get(url_for("api.reuses", type=type_reuse.type))
72
73
  assert200(response)
73
- assert len(response.json['data']) == 1
74
- assert response.json['data'][0]['id'] == str(type_reuse.id)
74
+ assert len(response.json["data"]) == 1
75
+ assert response.json["data"][0]["id"] == str(type_reuse.id)
75
76
 
76
77
  # filter on owner
77
- response = api.get(url_for('api.reuses', owner=owner.id))
78
+ response = api.get(url_for("api.reuses", owner=owner.id))
78
79
  assert200(response)
79
- assert len(response.json['data']) == 1
80
- assert response.json['data'][0]['id'] == str(owner_reuse.id)
80
+ assert len(response.json["data"]) == 1
81
+ assert response.json["data"][0]["id"] == str(owner_reuse.id)
81
82
 
82
83
  # filter on organization
83
- response = api.get(url_for('api.reuses', organization=org.id))
84
+ response = api.get(url_for("api.reuses", organization=org.id))
84
85
  assert200(response)
85
- assert len(response.json['data']) == 1
86
- assert response.json['data'][0]['id'] == str(org_reuse.id)
86
+ assert len(response.json["data"]) == 1
87
+ assert response.json["data"][0]["id"] == str(org_reuse.id)
87
88
 
88
- response = api.get(url_for('api.reuses', owner='owner-id'))
89
+ response = api.get(url_for("api.reuses", owner="owner-id"))
89
90
  assert400(response)
90
91
 
91
- response = api.get(url_for('api.reuses', organization='org-id'))
92
+ response = api.get(url_for("api.reuses", organization="org-id"))
92
93
  assert400(response)
93
94
 
94
95
  def test_reuse_api_get(self, api):
95
- '''It should fetch a reuse from the API'''
96
+ """It should fetch a reuse from the API"""
96
97
  reuse = ReuseFactory()
97
- response = api.get(url_for('api.reuse', reuse=reuse))
98
+ response = api.get(url_for("api.reuse", reuse=reuse))
98
99
  assert200(response)
99
100
 
100
101
  def test_reuse_api_get_deleted(self, api):
101
- '''It should not fetch a deleted reuse from the API and raise 410'''
102
+ """It should not fetch a deleted reuse from the API and raise 410"""
102
103
  reuse = ReuseFactory(deleted=datetime.utcnow())
103
- response = api.get(url_for('api.reuse', reuse=reuse))
104
+ response = api.get(url_for("api.reuse", reuse=reuse))
104
105
  assert410(response)
105
106
 
106
107
  def test_reuse_api_get_deleted_but_authorized(self, api):
107
- '''It should fetch a deleted reuse from the API if authorized'''
108
+ """It should fetch a deleted reuse from the API if authorized"""
108
109
  user = api.login()
109
110
  reuse = ReuseFactory(deleted=datetime.utcnow(), owner=user)
110
- response = api.get(url_for('api.reuse', reuse=reuse))
111
+ response = api.get(url_for("api.reuse", reuse=reuse))
111
112
  assert200(response)
112
113
 
113
114
  def test_reuse_api_create(self, api):
114
- '''It should create a reuse from the API'''
115
+ """It should create a reuse from the API"""
115
116
  data = ReuseFactory.as_dict()
116
117
  user = api.login()
117
- response = api.post(url_for('api.reuses'), data)
118
+ response = api.post(url_for("api.reuses"), data)
118
119
  assert201(response)
119
120
  assert Reuse.objects.count() == 1
120
121
 
@@ -123,13 +124,13 @@ class ReuseAPITest:
123
124
  assert reuse.organization is None
124
125
 
125
126
  def test_reuse_api_create_as_org(self, api):
126
- '''It should create a reuse as organization from the API'''
127
+ """It should create a reuse as organization from the API"""
127
128
  user = api.login()
128
129
  data = ReuseFactory.as_dict()
129
- member = Member(user=user, role='editor')
130
+ member = Member(user=user, role="editor")
130
131
  org = OrganizationFactory(members=[member])
131
- data['organization'] = str(org.id)
132
- response = api.post(url_for('api.reuses'), data)
132
+ data["organization"] = str(org.id)
133
+ response = api.post(url_for("api.reuses"), data)
133
134
  assert201(response)
134
135
  assert Reuse.objects.count() == 1
135
136
 
@@ -145,53 +146,53 @@ class ReuseAPITest:
145
146
  api.login()
146
147
  data = ReuseFactory.as_dict()
147
148
  org = OrganizationFactory()
148
- data['organization'] = str(org.id)
149
- response = api.post(url_for('api.reuses'), data)
149
+ data["organization"] = str(org.id)
150
+ response = api.post(url_for("api.reuses"), data)
150
151
  assert400(response)
151
152
  assert Reuse.objects.count() == 0
152
153
 
153
154
  def test_reuse_api_update(self, api):
154
- '''It should update a reuse from the API'''
155
+ """It should update a reuse from the API"""
155
156
  user = api.login()
156
157
  reuse = ReuseFactory(owner=user)
157
158
  data = reuse.to_dict()
158
- data['description'] = 'new description'
159
- response = api.put(url_for('api.reuse', reuse=reuse), data)
159
+ data["description"] = "new description"
160
+ response = api.put(url_for("api.reuse", reuse=reuse), data)
160
161
  assert200(response)
161
162
  assert Reuse.objects.count() == 1
162
- assert Reuse.objects.first().description == 'new description'
163
+ assert Reuse.objects.first().description == "new description"
163
164
 
164
165
  def test_reuse_api_update_deleted(self, api):
165
- '''It should not update a deleted reuse from the API and raise 410'''
166
+ """It should not update a deleted reuse from the API and raise 410"""
166
167
  api.login()
167
168
  reuse = ReuseFactory(deleted=datetime.utcnow())
168
- response = api.put(url_for('api.reuse', reuse=reuse), {})
169
+ response = api.put(url_for("api.reuse", reuse=reuse), {})
169
170
  assert410(response)
170
171
 
171
172
  def test_reuse_api_delete(self, api):
172
- '''It should delete a reuse from the API'''
173
+ """It should delete a reuse from the API"""
173
174
  user = api.login()
174
175
  reuse = ReuseFactory(owner=user)
175
- response = api.delete(url_for('api.reuse', reuse=reuse))
176
+ response = api.delete(url_for("api.reuse", reuse=reuse))
176
177
  assert204(response)
177
178
  assert Reuse.objects.count() == 1
178
179
  assert Reuse.objects[0].deleted is not None
179
180
 
180
181
  def test_reuse_api_delete_deleted(self, api):
181
- '''It should not delete a deleted reuse from the API and raise 410'''
182
+ """It should not delete a deleted reuse from the API and raise 410"""
182
183
  api.login()
183
184
  reuse = ReuseFactory(deleted=datetime.utcnow())
184
- response = api.delete(url_for('api.reuse', reuse=reuse))
185
+ response = api.delete(url_for("api.reuse", reuse=reuse))
185
186
  assert410(response)
186
187
 
187
188
  def test_reuse_api_add_dataset(self, api):
188
- '''It should add a dataset to a reuse from the API'''
189
+ """It should add a dataset to a reuse from the API"""
189
190
  user = api.login()
190
191
  reuse = ReuseFactory(owner=user)
191
192
 
192
193
  dataset = DatasetFactory()
193
- data = {'id': dataset.id, 'class': 'Dataset'}
194
- url = url_for('api.reuse_add_dataset', reuse=reuse)
194
+ data = {"id": dataset.id, "class": "Dataset"}
195
+ url = url_for("api.reuse_add_dataset", reuse=reuse)
195
196
  response = api.post(url, data)
196
197
  assert201(response)
197
198
  reuse.reload()
@@ -199,8 +200,8 @@ class ReuseAPITest:
199
200
  assert reuse.datasets[-1] == dataset
200
201
 
201
202
  dataset = DatasetFactory()
202
- data = {'id': dataset.id, 'class': 'Dataset'}
203
- url = url_for('api.reuse_add_dataset', reuse=reuse)
203
+ data = {"id": dataset.id, "class": "Dataset"}
204
+ url = url_for("api.reuse_add_dataset", reuse=reuse)
204
205
  response = api.post(url, data)
205
206
  assert201(response)
206
207
  reuse.reload()
@@ -208,13 +209,13 @@ class ReuseAPITest:
208
209
  assert reuse.datasets[-1] == dataset
209
210
 
210
211
  def test_reuse_api_add_dataset_twice(self, api):
211
- '''It should not add twice a dataset to a reuse from the API'''
212
+ """It should not add twice a dataset to a reuse from the API"""
212
213
  user = api.login()
213
214
  dataset = DatasetFactory()
214
215
  reuse = ReuseFactory(owner=user, datasets=[dataset])
215
216
 
216
- data = {'id': dataset.id, 'class': 'Dataset'}
217
- url = url_for('api.reuse_add_dataset', reuse=reuse)
217
+ data = {"id": dataset.id, "class": "Dataset"}
218
+ url = url_for("api.reuse_add_dataset", reuse=reuse)
218
219
  response = api.post(url, data)
219
220
  assert200(response)
220
221
  reuse.reload()
@@ -222,12 +223,12 @@ class ReuseAPITest:
222
223
  assert reuse.datasets[-1] == dataset
223
224
 
224
225
  def test_reuse_api_add_dataset_not_found(self, api):
225
- '''It should return 404 when adding an unknown dataset to a reuse'''
226
+ """It should return 404 when adding an unknown dataset to a reuse"""
226
227
  user = api.login()
227
228
  reuse = ReuseFactory(owner=user)
228
229
 
229
- data = {'id': 'not-found', 'class': 'Dataset'}
230
- url = url_for('api.reuse_add_dataset', reuse=reuse)
230
+ data = {"id": "not-found", "class": "Dataset"}
231
+ url = url_for("api.reuse_add_dataset", reuse=reuse)
231
232
  response = api.post(url, data)
232
233
 
233
234
  assert404(response)
@@ -235,59 +236,59 @@ class ReuseAPITest:
235
236
  assert len(reuse.datasets) == 0
236
237
 
237
238
  def test_reuse_api_feature(self, api):
238
- '''It should mark the reuse featured on POST'''
239
+ """It should mark the reuse featured on POST"""
239
240
  reuse = ReuseFactory(featured=False)
240
241
 
241
242
  with api.user(AdminFactory()):
242
- response = api.post(url_for('api.reuse_featured', reuse=reuse))
243
+ response = api.post(url_for("api.reuse_featured", reuse=reuse))
243
244
  assert200(response)
244
245
 
245
246
  reuse.reload()
246
247
  assert reuse.featured
247
248
 
248
249
  def test_reuse_api_feature_already(self, api):
249
- '''It shouldn't do anything to feature an already featured reuse'''
250
+ """It shouldn't do anything to feature an already featured reuse"""
250
251
  reuse = ReuseFactory(featured=True)
251
252
 
252
253
  with api.user(AdminFactory()):
253
- response = api.post(url_for('api.reuse_featured', reuse=reuse))
254
+ response = api.post(url_for("api.reuse_featured", reuse=reuse))
254
255
  assert200(response)
255
256
 
256
257
  reuse.reload()
257
258
  assert reuse.featured
258
259
 
259
260
  def test_reuse_api_unfeature(self, api):
260
- '''It should mark the reuse featured on POST'''
261
+ """It should mark the reuse featured on POST"""
261
262
  reuse = ReuseFactory(featured=True)
262
263
 
263
264
  with api.user(AdminFactory()):
264
- response = api.delete(url_for('api.reuse_featured', reuse=reuse))
265
+ response = api.delete(url_for("api.reuse_featured", reuse=reuse))
265
266
  assert200(response)
266
267
 
267
268
  reuse.reload()
268
269
  assert not reuse.featured
269
270
 
270
271
  def test_reuse_api_unfeature_already(self, api):
271
- '''It shouldn't do anything to unfeature a not featured reuse'''
272
+ """It shouldn't do anything to unfeature a not featured reuse"""
272
273
  reuse = ReuseFactory(featured=False)
273
274
 
274
275
  with api.user(AdminFactory()):
275
- response = api.delete(url_for('api.reuse_featured', reuse=reuse))
276
+ response = api.delete(url_for("api.reuse_featured", reuse=reuse))
276
277
  assert200(response)
277
278
 
278
279
  reuse.reload()
279
280
  assert not reuse.featured
280
281
 
281
282
  def test_follow_reuse(self, api):
282
- '''It should follow a reuse on POST'''
283
+ """It should follow a reuse on POST"""
283
284
  user = api.login()
284
285
  to_follow = ReuseFactory()
285
286
 
286
- response = api.post(url_for('api.reuse_followers', id=to_follow.id))
287
+ response = api.post(url_for("api.reuse_followers", id=to_follow.id))
287
288
  assert201(response)
288
289
 
289
290
  to_follow.count_followers()
290
- assert to_follow.get_metrics()['followers'] == 1
291
+ assert to_follow.get_metrics()["followers"] == 1
291
292
 
292
293
  assert Follow.objects.following(to_follow).count() == 0
293
294
  assert Follow.objects.followers(to_follow).count() == 1
@@ -297,17 +298,17 @@ class ReuseAPITest:
297
298
  assert Follow.objects.followers(user).count() == 0
298
299
 
299
300
  def test_unfollow_reuse(self, api):
300
- '''It should unfollow the reuse on DELETE'''
301
+ """It should unfollow the reuse on DELETE"""
301
302
  user = api.login()
302
303
  to_follow = ReuseFactory()
303
304
  Follow.objects.create(follower=user, following=to_follow)
304
305
 
305
- response = api.delete(url_for('api.reuse_followers', id=to_follow.id))
306
+ response = api.delete(url_for("api.reuse_followers", id=to_follow.id))
306
307
  assert200(response)
307
308
 
308
309
  nb_followers = Follow.objects.followers(to_follow).count()
309
310
 
310
- assert response.json['followers'] == nb_followers
311
+ assert response.json["followers"] == nb_followers
311
312
 
312
313
  assert Follow.objects.following(to_follow).count() == 0
313
314
  assert nb_followers == 0
@@ -315,68 +316,61 @@ class ReuseAPITest:
315
316
  assert Follow.objects.followers(user).count() == 0
316
317
 
317
318
  def test_suggest_reuses_api(self, api):
318
- '''It should suggest reuses'''
319
+ """It should suggest reuses"""
319
320
  for i in range(3):
320
321
  ReuseFactory(
321
- title='arealtestprefix-{0}'.format(i) if i % 2 else faker.word(),
322
+ title="arealtestprefix-{0}".format(i) if i % 2 else faker.word(),
322
323
  visible=True,
323
- metrics={"followers": i})
324
+ metrics={"followers": i},
325
+ )
324
326
  max_follower_reuse = ReuseFactory(
325
- title='arealtestprefix-4',
326
- visible=True,
327
- metrics={"followers": 10}
327
+ title="arealtestprefix-4", visible=True, metrics={"followers": 10}
328
328
  )
329
329
 
330
- response = api.get(url_for('api.suggest_reuses'),
331
- qs={'q': 'arealtestpref', 'size': '5'})
330
+ response = api.get(url_for("api.suggest_reuses"), qs={"q": "arealtestpref", "size": "5"})
332
331
  assert200(response)
333
332
 
334
333
  assert len(response.json) <= 5
335
334
  assert len(response.json) > 1
336
335
 
337
336
  for suggestion in response.json:
338
- assert 'id' in suggestion
339
- assert 'slug' in suggestion
340
- assert 'title' in suggestion
341
- assert 'image_url' in suggestion
342
- assert 'test' in suggestion['title']
343
- assert response.json[0]['id'] == str(max_follower_reuse.id)
337
+ assert "id" in suggestion
338
+ assert "slug" in suggestion
339
+ assert "title" in suggestion
340
+ assert "image_url" in suggestion
341
+ assert "test" in suggestion["title"]
342
+ assert response.json[0]["id"] == str(max_follower_reuse.id)
344
343
 
345
344
  def test_suggest_reuses_api_unicode(self, api):
346
- '''It should suggest reuses with special characters'''
345
+ """It should suggest reuses with special characters"""
347
346
  for i in range(4):
348
- ReuseFactory(
349
- title='testé-{0}'.format(i) if i % 2 else faker.word(),
350
- visible=True)
347
+ ReuseFactory(title="testé-{0}".format(i) if i % 2 else faker.word(), visible=True)
351
348
 
352
- response = api.get(url_for('api.suggest_reuses'),
353
- qs={'q': 'testé', 'size': '5'})
349
+ response = api.get(url_for("api.suggest_reuses"), qs={"q": "testé", "size": "5"})
354
350
  assert200(response)
355
351
 
356
352
  assert len(response.json) <= 5
357
353
  assert len(response.json) > 1
358
354
 
359
355
  for suggestion in response.json:
360
- assert 'id' in suggestion
361
- assert 'slug' in suggestion
362
- assert 'title' in suggestion
363
- assert 'image_url' in suggestion
364
- assert 'test' in suggestion['title']
356
+ assert "id" in suggestion
357
+ assert "slug" in suggestion
358
+ assert "title" in suggestion
359
+ assert "image_url" in suggestion
360
+ assert "test" in suggestion["title"]
365
361
 
366
362
  def test_suggest_reuses_api_no_match(self, api):
367
- '''It should not provide reuse suggestion if no match'''
363
+ """It should not provide reuse suggestion if no match"""
368
364
  ReuseFactory.create_batch(3, visible=True)
369
365
 
370
- response = api.get(url_for('api.suggest_reuses'),
371
- qs={'q': 'xxxxxx', 'size': '5'})
366
+ response = api.get(url_for("api.suggest_reuses"), qs={"q": "xxxxxx", "size": "5"})
372
367
  assert200(response)
373
368
  assert len(response.json) == 0
374
369
 
375
370
  def test_suggest_reuses_api_empty(self, api):
376
- '''It should not provide reuse suggestion if no data'''
371
+ """It should not provide reuse suggestion if no data"""
377
372
  # self.init_search()
378
- response = api.get(url_for('api.suggest_reuses'),
379
- qs={'q': 'xxxxxx', 'size': '5'})
373
+ response = api.get(url_for("api.suggest_reuses"), qs={"q": "xxxxxx", "size": "5"})
380
374
  assert200(response)
381
375
  assert len(response.json) == 0
382
376
 
@@ -387,15 +381,15 @@ class ReuseBadgeAPITest:
387
381
  @pytest.fixture(autouse=True)
388
382
  def setup(self, api, clean_db):
389
383
  # Register at least two badges
390
- Reuse.__badges__['test-1'] = 'Test 1'
391
- Reuse.__badges__['test-2'] = 'Test 2'
384
+ Reuse.__badges__["test-1"] = "Test 1"
385
+ Reuse.__badges__["test-2"] = "Test 2"
392
386
 
393
387
  self.factory = badge_factory(Reuse)
394
388
  self.user = api.login(AdminFactory())
395
389
  self.reuse = ReuseFactory()
396
390
 
397
391
  def test_list(self, api):
398
- response = api.get(url_for('api.available_reuse_badges'))
392
+ response = api.get(url_for("api.available_reuse_badges"))
399
393
  assert200(response)
400
394
  assert len(response.json) == len(Reuse.__badges__)
401
395
  for kind, label in Reuse.__badges__.items():
@@ -404,15 +398,15 @@ class ReuseBadgeAPITest:
404
398
 
405
399
  def test_create(self, api):
406
400
  data = self.factory.as_dict()
407
- response = api.post(url_for('api.reuse_badges', reuse=self.reuse), data)
401
+ response = api.post(url_for("api.reuse_badges", reuse=self.reuse), data)
408
402
  assert201(response)
409
403
  self.reuse.reload()
410
404
  assert len(self.reuse.badges) == 1
411
405
 
412
406
  def test_create_same(self, api):
413
407
  data = self.factory.as_dict()
414
- api.post(url_for('api.reuse_badges', reuse=self.reuse), data)
415
- response = api.post(url_for('api.reuse_badges', reuse=self.reuse), data)
408
+ api.post(url_for("api.reuse_badges", reuse=self.reuse), data)
409
+ response = api.post(url_for("api.reuse_badges", reuse=self.reuse), data)
416
410
  assert200(response)
417
411
  self.reuse.reload()
418
412
  assert len(self.reuse.badges) == 1
@@ -423,8 +417,8 @@ class ReuseBadgeAPITest:
423
417
  kinds_keys = list(Reuse.__badges__)
424
418
  self.reuse.add_badge(kinds_keys[0])
425
419
  data = self.factory.as_dict()
426
- data['kind'] = kinds_keys[1]
427
- response = api.post(url_for('api.reuse_badges', reuse=self.reuse), data)
420
+ data["kind"] = kinds_keys[1]
421
+ response = api.post(url_for("api.reuse_badges", reuse=self.reuse), data)
428
422
  assert201(response)
429
423
  self.reuse.reload()
430
424
  assert len(self.reuse.badges) == 2
@@ -432,16 +426,17 @@ class ReuseBadgeAPITest:
432
426
  def test_delete(self, api):
433
427
  badge = self.factory()
434
428
  self.reuse.add_badge(badge.kind)
435
- response = api.delete(url_for('api.reuse_badge',
436
- reuse=self.reuse,
437
- badge_kind=str(badge.kind)))
429
+ response = api.delete(
430
+ url_for("api.reuse_badge", reuse=self.reuse, badge_kind=str(badge.kind))
431
+ )
438
432
  assert204(response)
439
433
  self.reuse.reload()
440
434
  assert len(self.reuse.badges) == 0
441
435
 
442
436
  def test_delete_404(self, api):
443
- response = api.delete(url_for('api.reuse_badge', reuse=self.reuse,
444
- badge_kind=str(self.factory().kind)))
437
+ response = api.delete(
438
+ url_for("api.reuse_badge", reuse=self.reuse, badge_kind=str(self.factory().kind))
439
+ )
445
440
  assert404(response)
446
441
 
447
442
 
@@ -449,13 +444,13 @@ class ReuseReferencesAPITest:
449
444
  modules = []
450
445
 
451
446
  def test_reuse_types_list(self, api):
452
- '''It should fetch the reuse types list from the API'''
453
- response = api.get(url_for('api.reuse_types'))
447
+ """It should fetch the reuse types list from the API"""
448
+ response = api.get(url_for("api.reuse_types"))
454
449
  assert200(response)
455
450
  assert len(response.json) == len(REUSE_TYPES)
456
451
 
457
452
  def test_reuse_topics_list(self, api):
458
- '''It should fetch the reuse topics list from the API'''
459
- response = api.get(url_for('api.reuse_topics'))
453
+ """It should fetch the reuse topics list from the API"""
454
+ response = api.get(url_for("api.reuse_topics"))
460
455
  assert200(response)
461
456
  assert len(response.json) == len(REUSE_TOPICS)
@@ -10,15 +10,15 @@ class SwaggerBlueprintTest:
10
10
  modules = []
11
11
 
12
12
  def test_swagger_resource_type(self, api):
13
- response = api.get(url_for('api.specs'))
13
+ response = api.get(url_for("api.specs"))
14
14
  assert200(response)
15
15
  swagger = json.loads(response.data)
16
- expected = swagger['paths']['/datasets/{dataset}/resources/']
17
- expected = expected['put']['responses']['200']['schema']['type']
18
- assert expected == 'array'
16
+ expected = swagger["paths"]["/datasets/{dataset}/resources/"]
17
+ expected = expected["put"]["responses"]["200"]["schema"]["type"]
18
+ assert expected == "array"
19
19
 
20
20
  def test_swagger_specs_validate(self, api):
21
- response = api.get(url_for('api.specs'))
21
+ response = api.get(url_for("api.specs"))
22
22
  try:
23
23
  schemas.validate(response.json)
24
24
  except schemas.SchemaValidationError as e: