udata 12.0.2.dev15__py3-none-any.whl → 13.0.1.dev21__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 (258) hide show
  1. udata/api/__init__.py +1 -0
  2. udata/api_fields.py +10 -4
  3. udata/app.py +11 -10
  4. udata/auth/__init__.py +9 -10
  5. udata/auth/mails.py +137 -45
  6. udata/auth/views.py +5 -12
  7. udata/commands/__init__.py +2 -3
  8. udata/commands/info.py +1 -3
  9. udata/commands/tests/test_fixtures.py +6 -3
  10. udata/core/access_type/api.py +18 -0
  11. udata/core/access_type/constants.py +98 -0
  12. udata/core/access_type/models.py +44 -0
  13. udata/core/activity/models.py +1 -1
  14. udata/core/badges/models.py +1 -1
  15. udata/core/badges/tasks.py +35 -1
  16. udata/core/badges/tests/test_commands.py +2 -4
  17. udata/core/badges/tests/test_model.py +2 -2
  18. udata/core/badges/tests/test_tasks.py +55 -0
  19. udata/core/constants.py +1 -0
  20. udata/core/contact_point/models.py +8 -0
  21. udata/core/dataservices/api.py +3 -3
  22. udata/core/dataservices/apiv2.py +3 -1
  23. udata/core/dataservices/constants.py +0 -29
  24. udata/core/dataservices/models.py +44 -44
  25. udata/core/dataservices/rdf.py +2 -1
  26. udata/core/dataservices/search.py +5 -9
  27. udata/core/dataservices/tasks.py +33 -0
  28. udata/core/dataset/api_fields.py +11 -0
  29. udata/core/dataset/apiv2.py +11 -0
  30. udata/core/dataset/constants.py +0 -1
  31. udata/core/dataset/forms.py +29 -0
  32. udata/core/dataset/models.py +16 -4
  33. udata/core/dataset/rdf.py +2 -1
  34. udata/core/dataset/search.py +2 -2
  35. udata/core/dataset/tasks.py +86 -8
  36. udata/core/discussions/mails.py +63 -0
  37. udata/core/discussions/tasks.py +4 -18
  38. udata/core/metrics/__init__.py +0 -6
  39. udata/core/organization/api.py +3 -1
  40. udata/core/organization/mails.py +144 -0
  41. udata/core/organization/models.py +2 -1
  42. udata/core/organization/search.py +1 -1
  43. udata/core/organization/tasks.py +21 -49
  44. udata/core/pages/tests/test_api.py +0 -2
  45. udata/core/reuse/api.py +27 -1
  46. udata/core/reuse/mails.py +21 -0
  47. udata/core/reuse/models.py +10 -1
  48. udata/core/reuse/search.py +1 -1
  49. udata/core/reuse/tasks.py +2 -3
  50. udata/core/site/models.py +2 -6
  51. udata/core/spatial/tests/test_api.py +17 -20
  52. udata/core/spatial/tests/test_models.py +3 -3
  53. udata/core/user/mails.py +54 -0
  54. udata/core/user/models.py +2 -3
  55. udata/core/user/tasks.py +8 -23
  56. udata/core/user/tests/test_user_model.py +2 -6
  57. udata/entrypoints.py +0 -5
  58. udata/features/identicon/tests/test_backends.py +3 -13
  59. udata/forms/fields.py +3 -3
  60. udata/forms/widgets.py +2 -2
  61. udata/frontend/__init__.py +3 -32
  62. udata/harvest/actions.py +4 -9
  63. udata/harvest/api.py +5 -14
  64. udata/harvest/backends/__init__.py +20 -11
  65. udata/harvest/backends/base.py +2 -2
  66. udata/harvest/backends/ckan/harvesters.py +2 -1
  67. udata/harvest/backends/dcat.py +3 -0
  68. udata/harvest/backends/maaf.py +1 -0
  69. udata/harvest/commands.py +6 -4
  70. udata/harvest/forms.py +9 -6
  71. udata/harvest/tasks.py +3 -5
  72. udata/harvest/tests/ckan/test_ckan_backend.py +300 -337
  73. udata/harvest/tests/ckan/test_ckan_backend_errors.py +94 -99
  74. udata/harvest/tests/ckan/test_ckan_backend_filters.py +128 -122
  75. udata/harvest/tests/ckan/test_dkan_backend.py +39 -51
  76. udata/harvest/tests/dcat/datara--5a26b0f6-0ccf-46ad-ac58-734054b91977.rdf.xml +255 -0
  77. udata/harvest/tests/dcat/datara--f40c3860-7236-4b30-a141-23b8ae33f7b2.rdf.xml +289 -0
  78. udata/harvest/tests/factories.py +1 -1
  79. udata/harvest/tests/test_actions.py +11 -9
  80. udata/harvest/tests/test_api.py +4 -5
  81. udata/harvest/tests/test_base_backend.py +5 -4
  82. udata/harvest/tests/test_dcat_backend.py +50 -19
  83. udata/harvest/tests/test_models.py +2 -4
  84. udata/harvest/tests/test_notifications.py +2 -4
  85. udata/harvest/tests/test_tasks.py +2 -3
  86. udata/mail.py +90 -53
  87. udata/migrations/2025-01-05-dataservices-fields-changes.py +8 -14
  88. udata/migrations/2025-10-21-remove-ckan-harvest-modified-at.py +28 -0
  89. udata/migrations/2025-10-29-harvesters-sources-integrity.py +27 -0
  90. udata/mongo/taglist_field.py +3 -3
  91. udata/rdf.py +32 -15
  92. udata/sentry.py +3 -4
  93. udata/settings.py +7 -2
  94. udata/tags.py +5 -5
  95. udata/tasks.py +3 -3
  96. udata/templates/mail/message.html +65 -0
  97. udata/templates/mail/message.txt +16 -0
  98. udata/tests/__init__.py +40 -58
  99. udata/tests/api/__init__.py +87 -2
  100. udata/tests/api/test_activities_api.py +17 -23
  101. udata/tests/api/test_auth_api.py +2 -4
  102. udata/tests/api/test_contact_points.py +48 -54
  103. udata/tests/api/test_dataservices_api.py +57 -37
  104. udata/tests/api/test_datasets_api.py +146 -49
  105. udata/tests/api/test_me_api.py +4 -6
  106. udata/tests/api/test_organizations_api.py +19 -38
  107. udata/tests/api/test_reports_api.py +0 -4
  108. udata/tests/api/test_reuses_api.py +92 -19
  109. udata/tests/api/test_security_api.py +124 -0
  110. udata/tests/api/test_swagger.py +2 -3
  111. udata/tests/api/test_tags_api.py +6 -7
  112. udata/tests/api/test_transfer_api.py +0 -2
  113. udata/tests/api/test_user_api.py +8 -10
  114. udata/tests/apiv2/test_datasets.py +0 -4
  115. udata/tests/apiv2/test_me_api.py +0 -2
  116. udata/tests/apiv2/test_organizations.py +0 -2
  117. udata/tests/apiv2/test_swagger.py +2 -3
  118. udata/tests/apiv2/test_topics.py +0 -2
  119. udata/tests/cli/test_cli_base.py +14 -12
  120. udata/tests/cli/test_db_cli.py +51 -54
  121. udata/tests/contact_point/test_contact_point_models.py +2 -2
  122. udata/tests/dataservice/test_csv_adapter.py +2 -5
  123. udata/tests/dataservice/test_dataservice_rdf.py +8 -6
  124. udata/tests/dataservice/test_dataservice_tasks.py +36 -38
  125. udata/tests/dataset/test_csv_adapter.py +2 -5
  126. udata/tests/dataset/test_dataset_actions.py +2 -4
  127. udata/tests/dataset/test_dataset_commands.py +2 -4
  128. udata/tests/dataset/test_dataset_events.py +3 -3
  129. udata/tests/dataset/test_dataset_model.py +6 -7
  130. udata/tests/dataset/test_dataset_rdf.py +201 -12
  131. udata/tests/dataset/test_dataset_recommendations.py +2 -2
  132. udata/tests/dataset/test_dataset_tasks.py +66 -68
  133. udata/tests/dataset/test_resource_preview.py +39 -48
  134. udata/tests/dataset/test_transport_tasks.py +2 -2
  135. udata/tests/features/territories/__init__.py +0 -6
  136. udata/tests/features/territories/test_territories_api.py +25 -24
  137. udata/tests/forms/test_current_user_field.py +2 -2
  138. udata/tests/forms/test_dict_field.py +2 -4
  139. udata/tests/forms/test_extras_fields.py +2 -3
  140. udata/tests/forms/test_image_field.py +2 -2
  141. udata/tests/forms/test_model_field.py +2 -4
  142. udata/tests/forms/test_publish_as_field.py +2 -4
  143. udata/tests/forms/test_user_forms.py +26 -29
  144. udata/tests/frontend/test_auth.py +2 -3
  145. udata/tests/frontend/test_csv.py +5 -6
  146. udata/tests/frontend/test_error_handlers.py +2 -3
  147. udata/tests/frontend/test_hooks.py +5 -7
  148. udata/tests/frontend/test_markdown.py +3 -4
  149. udata/tests/helpers.py +2 -7
  150. udata/tests/metrics/test_metrics.py +52 -48
  151. udata/tests/metrics/test_tasks.py +154 -150
  152. udata/tests/organization/test_csv_adapter.py +2 -5
  153. udata/tests/organization/test_notifications.py +2 -4
  154. udata/tests/organization/test_organization_model.py +3 -4
  155. udata/tests/organization/test_organization_rdf.py +2 -8
  156. udata/tests/plugin.py +6 -110
  157. udata/tests/reuse/test_reuse_model.py +3 -4
  158. udata/tests/site/test_site_api.py +0 -2
  159. udata/tests/site/test_site_csv_exports.py +0 -2
  160. udata/tests/site/test_site_metrics.py +2 -4
  161. udata/tests/site/test_site_model.py +2 -2
  162. udata/tests/site/test_site_rdf.py +4 -7
  163. udata/tests/test_activity.py +3 -3
  164. udata/tests/test_api_fields.py +6 -9
  165. udata/tests/test_cors.py +0 -2
  166. udata/tests/test_dcat_commands.py +2 -3
  167. udata/tests/test_discussions.py +2 -7
  168. udata/tests/test_mail.py +150 -114
  169. udata/tests/test_migrations.py +413 -419
  170. udata/tests/test_model.py +10 -11
  171. udata/tests/test_notifications.py +2 -3
  172. udata/tests/test_owned.py +3 -3
  173. udata/tests/test_rdf.py +19 -15
  174. udata/tests/test_routing.py +5 -5
  175. udata/tests/test_storages.py +6 -5
  176. udata/tests/test_tags.py +2 -4
  177. udata/tests/test_topics.py +2 -4
  178. udata/tests/test_transfer.py +4 -5
  179. udata/tests/topic/test_topic_tasks.py +25 -27
  180. udata/tests/user/test_user_rdf.py +2 -8
  181. udata/tests/user/test_user_tasks.py +3 -5
  182. udata/tests/workers/test_jobs_commands.py +2 -2
  183. udata/tests/workers/test_tasks_routing.py +27 -27
  184. udata/translations/ar/LC_MESSAGES/udata.mo +0 -0
  185. udata/translations/ar/LC_MESSAGES/udata.po +369 -435
  186. udata/translations/de/LC_MESSAGES/udata.mo +0 -0
  187. udata/translations/de/LC_MESSAGES/udata.po +371 -437
  188. udata/translations/es/LC_MESSAGES/udata.mo +0 -0
  189. udata/translations/es/LC_MESSAGES/udata.po +369 -435
  190. udata/translations/fr/LC_MESSAGES/udata.mo +0 -0
  191. udata/translations/fr/LC_MESSAGES/udata.po +381 -447
  192. udata/translations/it/LC_MESSAGES/udata.mo +0 -0
  193. udata/translations/it/LC_MESSAGES/udata.po +371 -437
  194. udata/translations/pt/LC_MESSAGES/udata.mo +0 -0
  195. udata/translations/pt/LC_MESSAGES/udata.po +371 -437
  196. udata/translations/sr/LC_MESSAGES/udata.mo +0 -0
  197. udata/translations/sr/LC_MESSAGES/udata.po +372 -438
  198. udata/translations/udata.pot +379 -440
  199. udata/utils.py +14 -2
  200. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/METADATA +1 -2
  201. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/RECORD +205 -242
  202. udata/templates/mail/account_deleted.html +0 -5
  203. udata/templates/mail/account_deleted.txt +0 -6
  204. udata/templates/mail/account_inactivity.html +0 -40
  205. udata/templates/mail/account_inactivity.txt +0 -31
  206. udata/templates/mail/badge_added_association.html +0 -33
  207. udata/templates/mail/badge_added_association.txt +0 -11
  208. udata/templates/mail/badge_added_certified.html +0 -33
  209. udata/templates/mail/badge_added_certified.txt +0 -11
  210. udata/templates/mail/badge_added_company.html +0 -33
  211. udata/templates/mail/badge_added_company.txt +0 -11
  212. udata/templates/mail/badge_added_local_authority.html +0 -33
  213. udata/templates/mail/badge_added_local_authority.txt +0 -11
  214. udata/templates/mail/badge_added_public_service.html +0 -33
  215. udata/templates/mail/badge_added_public_service.txt +0 -11
  216. udata/templates/mail/discussion_closed.html +0 -47
  217. udata/templates/mail/discussion_closed.txt +0 -16
  218. udata/templates/mail/inactive_account_deleted.html +0 -5
  219. udata/templates/mail/inactive_account_deleted.txt +0 -6
  220. udata/templates/mail/membership_refused.html +0 -20
  221. udata/templates/mail/membership_refused.txt +0 -11
  222. udata/templates/mail/membership_request.html +0 -46
  223. udata/templates/mail/membership_request.txt +0 -12
  224. udata/templates/mail/new_discussion.html +0 -44
  225. udata/templates/mail/new_discussion.txt +0 -15
  226. udata/templates/mail/new_discussion_comment.html +0 -45
  227. udata/templates/mail/new_discussion_comment.txt +0 -16
  228. udata/templates/mail/new_member.html +0 -27
  229. udata/templates/mail/new_member.txt +0 -11
  230. udata/templates/mail/new_reuse.html +0 -37
  231. udata/templates/mail/new_reuse.txt +0 -9
  232. udata/templates/mail/test.html +0 -6
  233. udata/templates/mail/test.txt +0 -6
  234. udata/templates/mail/user_mail_card.html +0 -26
  235. udata/templates/security/email/base.html +0 -105
  236. udata/templates/security/email/base.txt +0 -6
  237. udata/templates/security/email/button.html +0 -3
  238. udata/templates/security/email/change_notice.html +0 -22
  239. udata/templates/security/email/change_notice.txt +0 -8
  240. udata/templates/security/email/confirmation_instructions.html +0 -20
  241. udata/templates/security/email/confirmation_instructions.txt +0 -7
  242. udata/templates/security/email/login_instructions.html +0 -19
  243. udata/templates/security/email/login_instructions.txt +0 -7
  244. udata/templates/security/email/reset_instructions.html +0 -24
  245. udata/templates/security/email/reset_instructions.txt +0 -9
  246. udata/templates/security/email/reset_notice.html +0 -11
  247. udata/templates/security/email/reset_notice.txt +0 -4
  248. udata/templates/security/email/welcome.html +0 -24
  249. udata/templates/security/email/welcome.txt +0 -9
  250. udata/templates/security/email/welcome_existing.html +0 -32
  251. udata/templates/security/email/welcome_existing.txt +0 -14
  252. udata/terms.md +0 -6
  253. udata/tests/frontend/__init__.py +0 -23
  254. udata/tests/metrics/conftest.py +0 -15
  255. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/WHEEL +0 -0
  256. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/entry_points.txt +0 -0
  257. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/licenses/LICENSE +0 -0
  258. {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/top_level.txt +0 -0
@@ -2,13 +2,15 @@ from datetime import datetime
2
2
 
3
3
  import pytest
4
4
  from bson import ObjectId
5
+ from mongoengine.connection import get_db
5
6
 
6
7
  from udata.models import Reuse
8
+ from udata.tests.api import PytestOnlyDBTestCase
7
9
 
8
10
 
9
11
  @pytest.fixture
10
- def migrations(db):
11
- db.migrations.insert_one(
12
+ def migrations():
13
+ get_db().migrations.insert_one(
12
14
  {
13
15
  "plugin": "udata",
14
16
  "filename": "test.py",
@@ -17,55 +19,50 @@ def migrations(db):
17
19
  "output": "ok",
18
20
  }
19
21
  )
20
- return db.migrations
21
-
22
-
23
- def test_unrecord_with_complete_filename(cli, migrations):
24
- """Should display help without errors"""
25
- result = cli("db unrecord udata test.py")
26
- assert result.exit_code == 0
27
- assert migrations.count_documents({}) == 0
28
-
29
-
30
- def test_unrecord_with_filename_without_extension(cli, migrations):
31
- """Should display help without errors"""
32
- result = cli("db unrecord udata test")
33
- assert result.exit_code == 0
34
- assert migrations.count_documents({}) == 0
35
-
36
-
37
- def test_unrecord_with_single_parameter(cli, migrations):
38
- """Should display help without errors"""
39
- result = cli("db unrecord udata:test.py")
40
- assert result.exit_code == 0
41
- assert migrations.count_documents({}) == 0
42
-
43
-
44
- def test_unrecord_with_single_parameter_without_extension(cli, migrations):
45
- """Should display help without errors"""
46
- result = cli("db unrecord udata:test")
47
- assert result.exit_code == 0
48
- assert migrations.count_documents({}) == 0
49
-
50
-
51
- def test_unrecord_without_parameters(cli, migrations):
52
- """Should display help without errors"""
53
- result = cli("db unrecord", check=False)
54
- assert result.exit_code != 0
55
- assert migrations.count_documents({}) == 1
56
-
57
-
58
- def test_unrecord_with_too_many_parameters(cli, migrations):
59
- """Should display help without errors"""
60
- result = cli("db unrecord udata test.py too many", check=False)
61
- assert result.exit_code != 0
62
- assert migrations.count_documents({}) == 1
63
-
64
-
65
- def test_check_references_report_listfield_missing(cli, clean_db):
66
- # The cli command `udata db check-integrity` should catch reuse object missing datasets field
67
- Reuse._get_collection().insert_one({"_id": ObjectId()})
68
-
69
- result = cli("db check-integrity --models Reuse", check=False)
70
- assert "Reuse.datasets(Dataset) — list…: 1" in result.output
71
- assert result.exit_code != 0
22
+ return get_db().migrations
23
+
24
+
25
+ class DBCliTest(PytestOnlyDBTestCase):
26
+ def test_unrecord_with_complete_filename(self, cli, migrations):
27
+ """Should display help without errors"""
28
+ result = cli("db unrecord udata test.py")
29
+ assert result.exit_code == 0
30
+ assert migrations.count_documents({}) == 0
31
+
32
+ def test_unrecord_with_filename_without_extension(self, cli, migrations):
33
+ """Should display help without errors"""
34
+ result = cli("db unrecord udata test")
35
+ assert result.exit_code == 0
36
+ assert migrations.count_documents({}) == 0
37
+
38
+ def test_unrecord_with_single_parameter(self, cli, migrations):
39
+ """Should display help without errors"""
40
+ result = cli("db unrecord udata:test.py")
41
+ assert result.exit_code == 0
42
+ assert migrations.count_documents({}) == 0
43
+
44
+ def test_unrecord_with_single_parameter_without_extension(self, cli, migrations):
45
+ """Should display help without errors"""
46
+ result = cli("db unrecord udata:test")
47
+ assert result.exit_code == 0
48
+ assert migrations.count_documents({}) == 0
49
+
50
+ def test_unrecord_without_parameters(self, cli, migrations):
51
+ """Should display help without errors"""
52
+ result = cli("db unrecord", check=False)
53
+ assert result.exit_code != 0
54
+ assert migrations.count_documents({}) == 1
55
+
56
+ def test_unrecord_with_too_many_parameters(self, cli, migrations):
57
+ """Should display help without errors"""
58
+ result = cli("db unrecord udata test.py too many", check=False)
59
+ assert result.exit_code != 0
60
+ assert migrations.count_documents({}) == 1
61
+
62
+ def test_check_references_report_listfield_missing(self, cli):
63
+ # The cli command `udata db check-integrity` should catch reuse object missing datasets field
64
+ Reuse._get_collection().insert_one({"_id": ObjectId()})
65
+
66
+ result = cli("db check-integrity --models Reuse", check=False)
67
+ assert "Reuse.datasets(Dataset) — list…: 1" in result.output
68
+ assert result.exit_code != 0
@@ -2,10 +2,10 @@ import pytest
2
2
 
3
3
  from udata.core.contact_point.factories import ContactPointFactory
4
4
  from udata.models import db
5
+ from udata.tests.api import PytestOnlyDBTestCase
5
6
 
6
7
 
7
- @pytest.mark.usefixtures("clean_db")
8
- class ContactPointTest:
8
+ class ContactPointTest(PytestOnlyDBTestCase):
9
9
  def test_validate_contact_role_needs_email_or_contact_form(self):
10
10
  with pytest.raises(db.ValidationError):
11
11
  ContactPointFactory(role="contact", email=None, contact_form=None)
@@ -1,17 +1,14 @@
1
1
  from datetime import datetime
2
2
 
3
- import pytest
4
-
5
3
  from udata.core.dataservices.csv import DataserviceCsvAdapter
6
4
  from udata.core.dataservices.factories import DataserviceFactory
7
5
  from udata.core.dataservices.models import Dataservice
8
6
  from udata.core.dataset.factories import DatasetFactory
9
7
  from udata.core.organization.factories import OrganizationFactory
8
+ from udata.tests.api import PytestOnlyDBTestCase
10
9
 
11
10
 
12
- @pytest.mark.frontend
13
- @pytest.mark.usefixtures("clean_db")
14
- class DataserviceCSVAdapterTest:
11
+ class DataserviceCSVAdapterTest(PytestOnlyDBTestCase):
15
12
  def test_dataservices_csv_adapter(self):
16
13
  dataservice = DataserviceFactory(
17
14
  created_at=datetime(2022, 12, 31),
@@ -6,6 +6,7 @@ from rdflib import BNode, Literal, URIRef
6
6
  from rdflib.namespace import RDF
7
7
  from rdflib.resource import Resource as RdfResource
8
8
 
9
+ from udata.core.constants import HVD
9
10
  from udata.core.dataservices.factories import DataserviceFactory, HarvestMetadataFactory
10
11
  from udata.core.dataservices.rdf import dataservice_to_rdf
11
12
  from udata.core.dataset.factories import DatasetFactory
@@ -16,13 +17,11 @@ from udata.rdf import (
16
17
  HVD_LEGISLATION,
17
18
  TAG_TO_EU_HVD_CATEGORIES,
18
19
  )
20
+ from udata.tests.api import PytestOnlyAPITestCase
19
21
  from udata.tests.helpers import assert200, assert_redirects
20
22
 
21
- pytestmark = pytest.mark.usefixtures("app")
22
23
 
23
-
24
- @pytest.mark.frontend
25
- class DataserviceToRdfTest:
24
+ class DataserviceToRdfTest(PytestOnlyAPITestCase):
26
25
  def test_minimal(self):
27
26
  dataservice = DataserviceFactory.build() # Does not have an URL
28
27
  d = dataservice_to_rdf(dataservice)
@@ -51,6 +50,7 @@ class DataserviceToRdfTest:
51
50
  def test_hvd_dataservice(self):
52
51
  """Test that a dataservice tagged hvd has appropriate DCAT-AP HVD properties"""
53
52
  dataservice = DataserviceFactory(tags=["hvd", "mobilite", "test"])
53
+ dataservice.add_badge(HVD)
54
54
  d = dataservice_to_rdf(dataservice)
55
55
 
56
56
  assert d.value(DCATAP.applicableLegislation).identifier == URIRef(HVD_LEGISLATION)
@@ -67,9 +67,12 @@ class DataserviceToRdfTest:
67
67
  dataset_hvd_2 = DatasetFactory(
68
68
  tags=["hvd", "statistiques", "mobilite", "geospatiales", "not-a-hvd-category"]
69
69
  )
70
+ dataset_hvd_1.add_badge(HVD)
71
+ dataset_hvd_2.add_badge(HVD)
70
72
  dataservice = DataserviceFactory(
71
73
  datasets=[dataset, dataset_hvd_1, dataset_hvd_2], tags=["hvd", "mobilite", "test"]
72
74
  )
75
+ dataservice.add_badge(HVD)
73
76
  d = dataservice_to_rdf(dataservice)
74
77
 
75
78
  assert d.value(DCATAP.applicableLegislation).identifier == URIRef(HVD_LEGISLATION)
@@ -83,8 +86,7 @@ class DataserviceToRdfTest:
83
86
  assert distrib.value(DCATAP.applicableLegislation).identifier == URIRef(HVD_LEGISLATION)
84
87
 
85
88
 
86
- @pytest.mark.frontend
87
- class DataserviceRdfViewsTest:
89
+ class DataserviceRdfViewsTest(PytestOnlyAPITestCase):
88
90
  def test_rdf_default_to_jsonld(self, client):
89
91
  dataservice = DataserviceFactory()
90
92
  expected = url_for("api.dataservice_rdf_format", dataservice=dataservice.id, _format="json")
@@ -1,47 +1,45 @@
1
- import pytest
2
-
3
1
  from udata.core.dataservices import tasks
4
2
  from udata.core.dataservices.models import Dataservice
5
3
  from udata.core.user.factories import UserFactory
6
4
  from udata.harvest.models import HarvestItem, HarvestJob
7
5
  from udata.harvest.tests.factories import HarvestJobFactory
8
6
  from udata.models import Discussion, Follow, Message, Transfer
7
+ from udata.tests.api import PytestOnlyDBTestCase
9
8
  from udata.utils import faker
10
9
 
11
- pytestmark = pytest.mark.usefixtures("clean_db")
12
-
13
-
14
- def test_purge_dataservices():
15
- dataservices = [
16
- Dataservice.objects.create(
17
- title="delete me", base_api_url="https://example.com/api", deleted_at="2016-01-01"
18
- ),
19
- Dataservice.objects.create(title="keep me", base_api_url="https://example.com/api"),
20
- ]
21
-
22
- user = UserFactory()
23
- transfer = Transfer.objects.create(
24
- owner=user,
25
- recipient=user,
26
- subject=dataservices[0],
27
- comment="comment",
28
- )
29
-
30
- discussion = Discussion.objects.create(
31
- subject=dataservices[0],
32
- user=user,
33
- title="test discussion",
34
- discussion=[Message(content=faker.sentence(), posted_by=user)],
35
- )
36
-
37
- follower = Follow.objects.create(follower=user, following=dataservices[0])
38
-
39
- HarvestJobFactory(items=[HarvestItem(dataservice=dataservices[0])])
40
-
41
- tasks.purge_dataservices()
42
10
 
43
- assert Dataservice.objects.count() == 1
44
- assert Transfer.objects.filter(id=transfer.id).count() == 0
45
- assert Discussion.objects.filter(id=discussion.id).count() == 0
46
- assert Follow.objects.filter(id=follower.id).count() == 0
47
- assert HarvestJob.objects.filter(items__dataservice=dataservices[0].id).count() == 0
11
+ class DataserviceTasksTest(PytestOnlyDBTestCase):
12
+ def test_purge_dataservices(self):
13
+ dataservices = [
14
+ Dataservice.objects.create(
15
+ title="delete me", base_api_url="https://example.com/api", deleted_at="2016-01-01"
16
+ ),
17
+ Dataservice.objects.create(title="keep me", base_api_url="https://example.com/api"),
18
+ ]
19
+
20
+ user = UserFactory()
21
+ transfer = Transfer.objects.create(
22
+ owner=user,
23
+ recipient=user,
24
+ subject=dataservices[0],
25
+ comment="comment",
26
+ )
27
+
28
+ discussion = Discussion.objects.create(
29
+ subject=dataservices[0],
30
+ user=user,
31
+ title="test discussion",
32
+ discussion=[Message(content=faker.sentence(), posted_by=user)],
33
+ )
34
+
35
+ follower = Follow.objects.create(follower=user, following=dataservices[0])
36
+
37
+ HarvestJobFactory(items=[HarvestItem(dataservice=dataservices[0])])
38
+
39
+ tasks.purge_dataservices()
40
+
41
+ assert Dataservice.objects.count() == 1
42
+ assert Transfer.objects.filter(id=transfer.id).count() == 0
43
+ assert Discussion.objects.filter(id=discussion.id).count() == 0
44
+ assert Follow.objects.filter(id=follower.id).count() == 0
45
+ assert HarvestJob.objects.filter(items__dataservice=dataservices[0].id).count() == 0
@@ -1,15 +1,12 @@
1
1
  from datetime import datetime, timedelta
2
2
 
3
- import pytest
4
-
5
3
  from udata.core.dataset.csv import DatasetCsvAdapter, ResourcesCsvAdapter
6
4
  from udata.core.dataset.factories import DatasetFactory, ResourceFactory
7
5
  from udata.core.dataset.models import Dataset
6
+ from udata.tests.api import PytestOnlyDBTestCase
8
7
 
9
8
 
10
- @pytest.mark.frontend
11
- @pytest.mark.usefixtures("clean_db")
12
- class DatasetCSVAdapterTest:
9
+ class DatasetCSVAdapterTest(PytestOnlyDBTestCase):
13
10
  def test_resources_csv_adapter(self):
14
11
  date_created = datetime(2022, 12, 31)
15
12
  date_modified = date_created + timedelta(days=1)
@@ -1,13 +1,11 @@
1
- import pytest
2
-
3
1
  from udata.core.dataset.actions import archive
4
2
  from udata.core.dataset.factories import DatasetFactory
5
3
  from udata.core.discussions.models import Discussion
6
4
  from udata.core.user.factories import UserFactory
5
+ from udata.tests.api import PytestOnlyDBTestCase
7
6
 
8
7
 
9
- @pytest.mark.usefixtures("clean_db")
10
- class DatasetActionsTest:
8
+ class DatasetActionsTest(PytestOnlyDBTestCase):
11
9
  def test_dataset_archive(self, app):
12
10
  user = UserFactory()
13
11
  app.config["ARCHIVE_COMMENT_USER_ID"] = user.id
@@ -1,12 +1,10 @@
1
1
  from tempfile import NamedTemporaryFile
2
2
 
3
- import pytest
4
-
5
3
  from udata.core.dataset.factories import DatasetFactory
4
+ from udata.tests.api import PytestOnlyDBTestCase
6
5
 
7
6
 
8
- @pytest.mark.usefixtures("clean_db")
9
- class DatasetCommandTest:
7
+ class DatasetCommandTest(PytestOnlyDBTestCase):
10
8
  def test_dataset_archive_one(self, cli):
11
9
  dataset = DatasetFactory()
12
10
 
@@ -7,12 +7,12 @@ from udata.core.dataset.events import serialize_resource_for_event
7
7
  from udata.core.dataset.factories import DatasetFactory, ResourceFactory
8
8
  from udata.core.dataset.models import Schema
9
9
  from udata.models import Dataset
10
+ from udata.tests.api import PytestOnlyDBTestCase
10
11
  from udata.tests.helpers import assert_emit
11
12
 
12
13
 
13
- @pytest.mark.usefixtures("clean_db")
14
- @pytest.mark.usefixtures("enable_resource_event")
15
- class DatasetEventsTest:
14
+ @pytest.mark.options(PUBLISH_ON_RESOURCE_EVENTS=True, RESOURCES_ANALYSER_URI="http://local.dev")
15
+ class DatasetEventsTest(PytestOnlyDBTestCase):
16
16
  @patch("requests.post")
17
17
  @pytest.mark.options(RESOURCES_ANALYSER_API_KEY=None)
18
18
  def test_publish_message_resource_created_no_api_key(self, mock_req):
@@ -37,13 +37,12 @@ from udata.core.followers.signals import on_follow, on_unfollow
37
37
  from udata.core.reuse.factories import ReuseFactory, VisibleReuseFactory
38
38
  from udata.core.user.factories import UserFactory
39
39
  from udata.models import Dataset, Follow, License, ResourceSchema, Reuse, Schema, db
40
+ from udata.tests.api import PytestOnlyDBTestCase
40
41
  from udata.tests.helpers import assert_emit, assert_equal_dates, assert_not_emit
41
42
  from udata.utils import faker
42
43
 
43
- pytestmark = pytest.mark.usefixtures("clean_db")
44
44
 
45
-
46
- class DatasetModelTest:
45
+ class DatasetModelTest(PytestOnlyDBTestCase):
47
46
  def test_add_resource(self):
48
47
  user = UserFactory()
49
48
  dataset = DatasetFactory(owner=user)
@@ -426,7 +425,7 @@ class DatasetModelTest:
426
425
  assert dataset.get_metrics()["dataservices"] == 0
427
426
 
428
427
 
429
- class ResourceModelTest:
428
+ class ResourceModelTest(PytestOnlyDBTestCase):
430
429
  def test_url_is_required(self):
431
430
  with pytest.raises(db.ValidationError):
432
431
  DatasetFactory(resources=[ResourceFactory(url=None)])
@@ -451,7 +450,7 @@ class ResourceModelTest:
451
450
  resource.save(signal_kwargs={"ignores": ["post_save"]})
452
451
 
453
452
 
454
- class LicenseModelTest:
453
+ class LicenseModelTest(PytestOnlyDBTestCase):
455
454
  @pytest.fixture(autouse=True)
456
455
  def setUp(self):
457
456
  # Feed the DB with random data to ensure true matching
@@ -672,7 +671,7 @@ class LicenseModelTest:
672
671
  assert license.id == found.id
673
672
 
674
673
 
675
- class ResourceSchemaTest:
674
+ class ResourceSchemaTest(PytestOnlyDBTestCase):
676
675
  @pytest.mark.options(SCHEMA_CATALOG_URL="https://example.com/notfound")
677
676
  def test_resource_schema_objects_404_endpoint(self, rmock):
678
677
  rmock.get("https://example.com/notfound", status_code=404)
@@ -787,7 +786,7 @@ class ResourceSchemaTest:
787
786
  resource.schema.clean(check_schema_in_catalog=True)
788
787
 
789
788
 
790
- class HarvestMetadataTest:
789
+ class HarvestMetadataTest(PytestOnlyDBTestCase):
791
790
  def test_harvest_dataset_metadata_validate_success(self):
792
791
  dataset = DatasetFactory()
793
792