udata 12.0.2.dev16__py3-none-any.whl → 12.0.2.dev18__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 (116) hide show
  1. udata/commands/tests/test_fixtures.py +6 -3
  2. udata/core/badges/tests/test_commands.py +2 -4
  3. udata/core/badges/tests/test_model.py +2 -2
  4. udata/core/pages/tests/test_api.py +0 -2
  5. udata/core/spatial/tests/test_api.py +17 -20
  6. udata/core/spatial/tests/test_models.py +3 -3
  7. udata/core/user/tests/test_user_model.py +2 -6
  8. udata/features/identicon/tests/test_backends.py +3 -13
  9. udata/forms/fields.py +3 -3
  10. udata/forms/widgets.py +2 -2
  11. udata/harvest/tests/ckan/test_ckan_backend.py +300 -337
  12. udata/harvest/tests/ckan/test_ckan_backend_errors.py +94 -99
  13. udata/harvest/tests/ckan/test_ckan_backend_filters.py +128 -122
  14. udata/harvest/tests/ckan/test_dkan_backend.py +39 -51
  15. udata/harvest/tests/test_actions.py +7 -7
  16. udata/harvest/tests/test_api.py +2 -4
  17. udata/harvest/tests/test_base_backend.py +3 -4
  18. udata/harvest/tests/test_dcat_backend.py +5 -16
  19. udata/harvest/tests/test_models.py +2 -4
  20. udata/harvest/tests/test_notifications.py +2 -4
  21. udata/harvest/tests/test_tasks.py +2 -3
  22. udata/mongo/taglist_field.py +3 -3
  23. udata/settings.py +3 -0
  24. udata/tags.py +5 -5
  25. udata/tests/__init__.py +40 -58
  26. udata/tests/api/__init__.py +87 -2
  27. udata/tests/api/test_activities_api.py +17 -23
  28. udata/tests/api/test_auth_api.py +2 -4
  29. udata/tests/api/test_contact_points.py +48 -54
  30. udata/tests/api/test_dataservices_api.py +0 -2
  31. udata/tests/api/test_datasets_api.py +27 -49
  32. udata/tests/api/test_me_api.py +4 -6
  33. udata/tests/api/test_organizations_api.py +19 -38
  34. udata/tests/api/test_reports_api.py +0 -4
  35. udata/tests/api/test_reuses_api.py +9 -19
  36. udata/tests/api/test_swagger.py +2 -3
  37. udata/tests/api/test_tags_api.py +6 -7
  38. udata/tests/api/test_transfer_api.py +0 -2
  39. udata/tests/api/test_user_api.py +8 -10
  40. udata/tests/apiv2/test_datasets.py +0 -4
  41. udata/tests/apiv2/test_me_api.py +0 -2
  42. udata/tests/apiv2/test_organizations.py +0 -2
  43. udata/tests/apiv2/test_swagger.py +2 -3
  44. udata/tests/apiv2/test_topics.py +0 -2
  45. udata/tests/cli/test_cli_base.py +14 -12
  46. udata/tests/cli/test_db_cli.py +51 -54
  47. udata/tests/contact_point/test_contact_point_models.py +2 -2
  48. udata/tests/dataservice/test_csv_adapter.py +2 -5
  49. udata/tests/dataservice/test_dataservice_rdf.py +3 -6
  50. udata/tests/dataservice/test_dataservice_tasks.py +36 -38
  51. udata/tests/dataset/test_csv_adapter.py +2 -5
  52. udata/tests/dataset/test_dataset_actions.py +2 -4
  53. udata/tests/dataset/test_dataset_commands.py +2 -4
  54. udata/tests/dataset/test_dataset_events.py +3 -3
  55. udata/tests/dataset/test_dataset_model.py +6 -7
  56. udata/tests/dataset/test_dataset_rdf.py +6 -9
  57. udata/tests/dataset/test_dataset_recommendations.py +2 -2
  58. udata/tests/dataset/test_dataset_tasks.py +66 -68
  59. udata/tests/dataset/test_resource_preview.py +39 -48
  60. udata/tests/dataset/test_transport_tasks.py +2 -2
  61. udata/tests/features/territories/__init__.py +0 -6
  62. udata/tests/features/territories/test_territories_api.py +25 -24
  63. udata/tests/forms/test_current_user_field.py +2 -2
  64. udata/tests/forms/test_dict_field.py +2 -4
  65. udata/tests/forms/test_extras_fields.py +2 -3
  66. udata/tests/forms/test_image_field.py +2 -2
  67. udata/tests/forms/test_model_field.py +2 -4
  68. udata/tests/forms/test_publish_as_field.py +2 -4
  69. udata/tests/forms/test_user_forms.py +26 -29
  70. udata/tests/frontend/test_auth.py +2 -3
  71. udata/tests/frontend/test_csv.py +5 -6
  72. udata/tests/frontend/test_error_handlers.py +2 -3
  73. udata/tests/frontend/test_hooks.py +5 -7
  74. udata/tests/frontend/test_markdown.py +3 -4
  75. udata/tests/helpers.py +2 -7
  76. udata/tests/metrics/test_metrics.py +52 -48
  77. udata/tests/metrics/test_tasks.py +154 -150
  78. udata/tests/organization/test_csv_adapter.py +2 -5
  79. udata/tests/organization/test_notifications.py +2 -4
  80. udata/tests/organization/test_organization_model.py +3 -4
  81. udata/tests/organization/test_organization_rdf.py +2 -8
  82. udata/tests/plugin.py +6 -110
  83. udata/tests/reuse/test_reuse_model.py +3 -4
  84. udata/tests/site/test_site_api.py +0 -2
  85. udata/tests/site/test_site_csv_exports.py +0 -2
  86. udata/tests/site/test_site_metrics.py +2 -4
  87. udata/tests/site/test_site_model.py +2 -2
  88. udata/tests/site/test_site_rdf.py +3 -6
  89. udata/tests/test_activity.py +3 -3
  90. udata/tests/test_api_fields.py +6 -9
  91. udata/tests/test_cors.py +0 -2
  92. udata/tests/test_dcat_commands.py +2 -3
  93. udata/tests/test_discussions.py +2 -7
  94. udata/tests/test_mail.py +4 -10
  95. udata/tests/test_migrations.py +413 -419
  96. udata/tests/test_model.py +10 -11
  97. udata/tests/test_notifications.py +2 -3
  98. udata/tests/test_owned.py +3 -3
  99. udata/tests/test_routing.py +5 -5
  100. udata/tests/test_storages.py +6 -5
  101. udata/tests/test_tags.py +2 -4
  102. udata/tests/test_topics.py +2 -4
  103. udata/tests/test_transfer.py +4 -5
  104. udata/tests/topic/test_topic_tasks.py +25 -27
  105. udata/tests/user/test_user_rdf.py +2 -8
  106. udata/tests/workers/test_jobs_commands.py +2 -2
  107. udata/tests/workers/test_tasks_routing.py +27 -27
  108. udata/utils.py +1 -1
  109. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/METADATA +1 -1
  110. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/RECORD +114 -116
  111. udata/tests/frontend/__init__.py +0 -23
  112. udata/tests/metrics/conftest.py +0 -15
  113. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/WHEEL +0 -0
  114. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/entry_points.txt +0 -0
  115. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/licenses/LICENSE +0 -0
  116. {udata-12.0.2.dev16.dist-info → udata-12.0.2.dev18.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,3 @@
1
- import pytest
2
1
  from flask import url_for
3
2
 
4
3
  from udata.core.contact_point.factories import ContactPointFactory
@@ -7,17 +6,12 @@ from udata.core.organization.factories import OrganizationFactory
7
6
  from udata.core.organization.models import Member
8
7
  from udata.i18n import gettext as _
9
8
  from udata.models import ContactPoint
9
+ from udata.tests.api import APITestCase
10
10
  from udata.tests.helpers import assert200, assert201, assert204, assert400, assert403
11
11
  from udata.utils import faker
12
12
 
13
- pytestmark = [
14
- pytest.mark.usefixtures("clean_db"),
15
- ]
16
-
17
-
18
- class ContactPointAPITest:
19
- modules = []
20
13
 
14
+ class ContactPointAPITest(APITestCase):
21
15
  def test_get_or_create(self):
22
16
  org = OrganizationFactory()
23
17
  contact_point, created = ContactPoint.objects().get_or_create(
@@ -51,46 +45,46 @@ class ContactPointAPITest:
51
45
  assert created
52
46
  assert contact_point.name == "Another"
53
47
 
54
- def test_contact_point_api_create(self, api):
55
- user = api.login()
48
+ def test_contact_point_api_create(self):
49
+ user = self.login()
56
50
  data = {
57
51
  "name": faker.word(),
58
52
  "email": faker.email(),
59
53
  "contact_form": faker.url(),
60
54
  "role": "contact",
61
55
  }
62
- response = api.post(url_for("api.contact_points"), data=data)
56
+ response = self.post(url_for("api.contact_points"), data=data)
63
57
  assert201(response)
64
58
  assert ContactPoint.objects.count() == 1
65
59
 
66
60
  contact_point = ContactPoint.objects.first()
67
61
  assert contact_point.owner.id == user.id
68
62
 
69
- def test_contact_point_api_create_email_or_contact_form(self, api):
70
- api.login()
63
+ def test_contact_point_api_create_email_or_contact_form(self):
64
+ self.login()
71
65
  data = {"name": faker.word(), "contact_form": faker.url(), "role": "contact"}
72
- response = api.post(url_for("api.contact_points"), data=data)
66
+ response = self.post(url_for("api.contact_points"), data=data)
73
67
  assert201(response)
74
68
  assert ContactPoint.objects.count() == 1
75
69
 
76
70
  data = {"name": faker.word(), "email": faker.email(), "role": "contact"}
77
- response = api.post(url_for("api.contact_points"), data=data)
71
+ response = self.post(url_for("api.contact_points"), data=data)
78
72
  assert201(response)
79
73
  assert ContactPoint.objects.count() == 2
80
74
 
81
- def test_contact_point_duplicate_creation(self, api):
82
- api.login()
75
+ def test_contact_point_duplicate_creation(self):
76
+ self.login()
83
77
  data = {"name": faker.word(), "contact_form": faker.url(), "role": "contact"}
84
- response = api.post(url_for("api.contact_points"), data=data)
78
+ response = self.post(url_for("api.contact_points"), data=data)
85
79
  assert201(response)
86
80
  assert ContactPoint.objects.count() == 1
87
81
 
88
- response = api.post(url_for("api.contact_points"), data=data)
82
+ response = self.post(url_for("api.contact_points"), data=data)
89
83
  assert200(response)
90
84
  assert ContactPoint.objects.count() == 1
91
85
 
92
- def test_contact_point_for_different_org(self, api):
93
- user = api.login()
86
+ def test_contact_point_for_different_org(self):
87
+ user = self.login()
94
88
  member = Member(user=user, role="editor")
95
89
  org_a = OrganizationFactory(members=[member])
96
90
 
@@ -100,11 +94,11 @@ class ContactPointAPITest:
100
94
  "role": "contact",
101
95
  "organization": str(org_a.id),
102
96
  }
103
- response = api.post(url_for("api.contact_points"), data=data)
97
+ response = self.post(url_for("api.contact_points"), data=data)
104
98
  assert201(response)
105
99
  assert ContactPoint.objects.count() == 1
106
100
 
107
- response = api.post(url_for("api.contact_points"), data=data)
101
+ response = self.post(url_for("api.contact_points"), data=data)
108
102
  assert200(response)
109
103
  assert ContactPoint.objects.count() == 1
110
104
 
@@ -114,39 +108,39 @@ class ContactPointAPITest:
114
108
 
115
109
  org_b = OrganizationFactory(members=[])
116
110
  data["organization"] = str(org_b.id)
117
- response = api.post(url_for("api.contact_points"), data=data)
111
+ response = self.post(url_for("api.contact_points"), data=data)
118
112
  assert400(response)
119
113
  assert ContactPoint.objects.count() == 1
120
114
 
121
115
  org_b.members = [Member(user=user, role="editor")]
122
116
  org_b.save()
123
117
 
124
- response = api.post(url_for("api.contact_points"), data=data)
118
+ response = self.post(url_for("api.contact_points"), data=data)
125
119
  assert201(response)
126
120
  assert ContactPoint.objects.count() == 2
127
121
 
128
- def test_contact_point_api_invalid_email(self, api):
129
- api.login()
122
+ def test_contact_point_api_invalid_email(self):
123
+ self.login()
130
124
  data = {"name": faker.word(), "email": faker.word(), "role": "contact"}
131
- response = api.post(url_for("api.contact_points"), data=data)
125
+ response = self.post(url_for("api.contact_points"), data=data)
132
126
  assert400(response)
133
127
  assert "email" in response.json["errors"]
134
128
  assert ContactPoint.objects.count() == 0
135
129
 
136
- def test_contact_point_missing_contact_information(self, api):
137
- api.login()
130
+ def test_contact_point_missing_contact_information(self):
131
+ self.login()
138
132
  data = {"name": faker.word(), "role": "contact"}
139
- response = api.post(url_for("api.contact_points"), data=data)
133
+ response = self.post(url_for("api.contact_points"), data=data)
140
134
  assert400(response)
141
135
  assert response.json["message"] == _(
142
136
  "At least an email or a contact form is required for a contact point"
143
137
  )
144
138
  assert ContactPoint.objects.count() == 0
145
139
 
146
- def test_contact_point_missing_role(self, api):
147
- api.login()
140
+ def test_contact_point_missing_role(self):
141
+ self.login()
148
142
  data = {"name": faker.word(), "email": faker.email()}
149
- response = api.post(url_for("api.contact_points"), data=data)
143
+ response = self.post(url_for("api.contact_points"), data=data)
150
144
  assert400(response)
151
145
  assert (
152
146
  response.json["message"]
@@ -154,70 +148,70 @@ class ContactPointAPITest:
154
148
  )
155
149
  assert ContactPoint.objects.count() == 0
156
150
 
157
- def test_contact_point_no_need_for_email_for_role_other_than_contact(self, api):
158
- api.login()
151
+ def test_contact_point_no_need_for_email_for_role_other_than_contact(self):
152
+ self.login()
159
153
  roles_other_than_contact = [role_ for role_ in CONTACT_ROLES.keys() if role_ != "contact"]
160
154
  for index, role in enumerate(roles_other_than_contact):
161
155
  data = {"name": faker.word(), "role": role}
162
- response = api.post(url_for("api.contact_points"), data=data)
156
+ response = self.post(url_for("api.contact_points"), data=data)
163
157
  assert201(response)
164
158
  assert ContactPoint.objects.count() == index + 1
165
159
 
166
- def test_contact_point_api_update(self, api):
167
- user = api.login()
160
+ def test_contact_point_api_update(self):
161
+ user = self.login()
168
162
  member = Member(user=user, role="editor")
169
163
  org = OrganizationFactory(members=[member])
170
164
  contact_point = ContactPointFactory(organization=org)
171
165
  data = contact_point.to_dict()
172
166
  data["email"] = "new.email@newdomain.com"
173
- response = api.put(url_for("api.contact_point", contact_point=contact_point), data)
167
+ response = self.put(url_for("api.contact_point", contact_point=contact_point), data)
174
168
  assert200(response)
175
169
  assert ContactPoint.objects.count() == 1
176
170
  assert ContactPoint.objects.first().email == "new.email@newdomain.com"
177
171
 
178
- def test_contact_point_api_update_to_existing_contact_point(self, api):
179
- user = api.login()
172
+ def test_contact_point_api_update_to_existing_contact_point(self):
173
+ user = self.login()
180
174
  contact_point_a = ContactPointFactory(email="a@example.org", owner=user)
181
175
  contact_point_b = ContactPointFactory(email="b@example.org", owner=user)
182
176
 
183
177
  data_b = contact_point_b.to_dict()
184
- response = api.put(url_for("api.contact_point", contact_point=contact_point_a), data_b)
178
+ response = self.put(url_for("api.contact_point", contact_point=contact_point_a), data_b)
185
179
  assert400(response)
186
180
  assert ContactPoint.objects.count() == 2
187
181
 
188
182
  contact_point_a.reload()
189
183
  assert contact_point_a.email == "a@example.org"
190
184
 
191
- def test_contact_point_api_update_forbidden(self, api):
192
- api.login()
185
+ def test_contact_point_api_update_forbidden(self):
186
+ self.login()
193
187
  org = OrganizationFactory()
194
188
  contact_point = ContactPointFactory(organization=org)
195
189
  data = contact_point.to_dict()
196
190
  data["email"] = "new.email@newdomain.com"
197
- response = api.put(url_for("api.contact_point", contact_point=contact_point), data)
191
+ response = self.put(url_for("api.contact_point", contact_point=contact_point), data)
198
192
  assert403(response)
199
193
  assert ContactPoint.objects.count() == 1
200
194
  assert ContactPoint.objects.first().email == contact_point.email
201
195
 
202
- def test_contact_point_api_delete(self, api):
203
- user = api.login()
196
+ def test_contact_point_api_delete(self):
197
+ user = self.login()
204
198
  member = Member(user=user, role="editor")
205
199
  org = OrganizationFactory(members=[member])
206
200
  contact_point = ContactPointFactory(organization=org)
207
- response = api.delete(url_for("api.contact_point", contact_point=contact_point))
201
+ response = self.delete(url_for("api.contact_point", contact_point=contact_point))
208
202
  assert204(response)
209
203
  assert ContactPoint.objects.count() == 0
210
204
 
211
- def test_contact_point_roles_list(self, api):
205
+ def test_contact_point_roles_list(self):
212
206
  """It should fetch the contact point roles list from the API"""
213
- response = api.get(url_for("api.contact_point_roles"))
207
+ response = self.get(url_for("api.contact_point_roles"))
214
208
  assert200(response)
215
209
  assert len(response.json) == len(CONTACT_ROLES)
216
210
 
217
- def test_contact_point_api_delete_forbidden(self, api):
218
- api.login()
211
+ def test_contact_point_api_delete_forbidden(self):
212
+ self.login()
219
213
  org = OrganizationFactory()
220
214
  contact_point = ContactPointFactory(organization=org)
221
- response = api.delete(url_for("api.contact_point", contact_point=contact_point))
215
+ response = self.delete(url_for("api.contact_point", contact_point=contact_point))
222
216
  assert403(response)
223
217
  assert ContactPoint.objects.count() == 1
@@ -34,8 +34,6 @@ def dataservice_in_response(response: TestResponse, dataservice: Dataservice) ->
34
34
 
35
35
 
36
36
  class DataserviceAPITest(APITestCase):
37
- modules = []
38
-
39
37
  def test_dataservice_api_get(self):
40
38
  """It should fetch a dataservice from the API"""
41
39
  dataservice = DataserviceFactory()
@@ -42,12 +42,12 @@ from udata.core.topic.factories import TopicElementDatasetFactory, TopicFactory
42
42
  from udata.core.user.factories import AdminFactory, UserFactory
43
43
  from udata.i18n import gettext as _
44
44
  from udata.models import CommunityResource, Dataset, Follow, Member, db
45
- from udata.tags import MAX_TAG_LENGTH, MIN_TAG_LENGTH
45
+ from udata.tags import TAG_MAX_LENGTH, TAG_MIN_LENGTH
46
46
  from udata.tests.features.territories import create_geozones_fixtures
47
47
  from udata.tests.helpers import assert200, assert404
48
48
  from udata.utils import faker, unique_string
49
49
 
50
- from . import APITestCase
50
+ from . import APITestCase, PytestOnlyAPITestCase
51
51
 
52
52
  SAMPLE_GEOM = {
53
53
  "type": "MultiPolygon",
@@ -67,8 +67,6 @@ def dataset_in_response(response: TestResponse, dataset: Dataset) -> bool:
67
67
 
68
68
 
69
69
  class DatasetAPITest(APITestCase):
70
- modules = []
71
-
72
70
  def test_dataset_api_list(self):
73
71
  """It should fetch a dataset list from the API"""
74
72
  datasets = [DatasetFactory() for i in range(2)]
@@ -632,19 +630,21 @@ class DatasetAPITest(APITestCase):
632
630
  dataset = Dataset.objects.first()
633
631
  self.assertEqual(dataset.tags, sorted(data["tags"]))
634
632
 
633
+ @pytest.mark.options(TAG_MIN_LENGTH=3, TAG_MAX_LENGTH=10)
635
634
  def test_dataset_api_fail_to_create_too_short_tags(self):
636
635
  """It should fail to create a dataset from the API because
637
636
  the tag is too short"""
638
637
  data = DatasetFactory.as_dict()
639
- data["tags"] = [unique_string(MIN_TAG_LENGTH - 1)]
638
+ data["tags"] = [unique_string(TAG_MIN_LENGTH - 1)]
640
639
  with self.api_user():
641
640
  response = self.post(url_for("api.datasets"), data)
642
641
  self.assertStatus(response, 400)
643
642
 
643
+ @pytest.mark.options(TAG_MIN_LENGTH=3, TAG_MAX_LENGTH=10)
644
644
  def test_dataset_api_fail_to_create_too_long_tags(self):
645
645
  """Should fail creating a dataset with a tag long"""
646
646
  data = DatasetFactory.as_dict()
647
- data["tags"] = [unique_string(MAX_TAG_LENGTH + 1)]
647
+ data["tags"] = [unique_string(TAG_MAX_LENGTH + 1)]
648
648
  with self.api_user():
649
649
  response = self.post(url_for("api.datasets"), data)
650
650
  self.assertStatus(response, 400)
@@ -1423,7 +1423,7 @@ class DatasetsFeedAPItest(APITestCase):
1423
1423
  assert "<h1>" in response.text
1424
1424
  assert "<ul>" in response.text
1425
1425
 
1426
- @pytest.mark.options(DELAY_BEFORE_APPEARING_IN_RSS_FEED=0)
1426
+ @pytest.mark.options(DELAY_BEFORE_APPEARING_IN_RSS_FEED=0, CDATA_BASE_URL="http://example.org")
1427
1427
  def test_feed_id_uri_is_valid(self):
1428
1428
  DatasetFactory()
1429
1429
 
@@ -1503,8 +1503,6 @@ class DatasetBadgeAPITest(APITestCase):
1503
1503
 
1504
1504
 
1505
1505
  class DatasetResourceAPITest(APITestCase):
1506
- modules = None
1507
-
1508
1506
  def setUp(self):
1509
1507
  self.login()
1510
1508
  self.dataset = DatasetFactory(owner=self.user)
@@ -1953,35 +1951,25 @@ class DatasetResourceAPITest(APITestCase):
1953
1951
  self.assertEqual(Follow.objects.following(user).count(), 0)
1954
1952
  self.assertEqual(Follow.objects.followers(user).count(), 0)
1955
1953
 
1954
+ @pytest.mark.options(ALLOWED_RESOURCES_EXTENSIONS=["txt", "html", "kml", "kml-1", "qml", "xml"])
1956
1955
  def test_suggest_formats_api(self):
1957
- """It should suggest formats"""
1958
- DatasetFactory(
1959
- resources=[
1960
- ResourceFactory(format=f) for f in (faker.word(), faker.word(), "kml", "kml-1")
1961
- ]
1962
- )
1963
-
1964
- response = self.get(url_for("api.suggest_formats"), qs={"q": "km", "size": "5"})
1956
+ response = self.get(url_for("api.suggest_formats", q="km", size=5))
1965
1957
  self.assert200(response)
1966
1958
 
1967
- self.assertLessEqual(len(response.json), 5)
1968
- self.assertGreater(len(response.json), 1)
1969
-
1970
- for suggestion in response.json:
1971
- self.assertIn("text", suggestion)
1972
- self.assertIn("km", suggestion["text"])
1959
+ self.assertEqual(len(response.json), 2)
1960
+ self.assertEqual(response.json[0]["text"], "kml")
1961
+ self.assertEqual(response.json[1]["text"], "kml-1")
1973
1962
 
1963
+ @pytest.mark.options(ALLOWED_RESOURCES_EXTENSIONS=["txt", "html", "kml", "kml-1", "qml", "xml"])
1974
1964
  def test_suggest_format_api_no_match(self):
1975
- """It should not provide format suggestion if no match"""
1976
- DatasetFactory(resources=[ResourceFactory(format=faker.word()) for _ in range(3)])
1977
-
1978
- response = self.get(url_for("api.suggest_formats"), qs={"q": "test", "size": "5"})
1965
+ response = self.get(url_for("api.suggest_formats", q="test", size=5))
1979
1966
  self.assert200(response)
1980
1967
  self.assertEqual(len(response.json), 0)
1981
1968
 
1969
+ @pytest.mark.options(ALLOWED_RESOURCES_EXTENSIONS=[])
1982
1970
  def test_suggest_format_api_empty(self):
1983
1971
  """It should not provide format suggestion if no data"""
1984
- response = self.get(url_for("api.suggest_formats"), qs={"q": "test", "size": "5"})
1972
+ response = self.get(url_for("api.suggest_formats", q="txt", size=5))
1985
1973
  self.assert200(response)
1986
1974
  self.assertEqual(len(response.json), 0)
1987
1975
 
@@ -1999,7 +1987,7 @@ class DatasetResourceAPITest(APITestCase):
1999
1987
  ]
2000
1988
  )
2001
1989
 
2002
- response = self.get(url_for("api.suggest_mime"), qs={"q": "js", "size": "5"})
1990
+ response = self.get(url_for("api.suggest_mime", q="js", size=5))
2003
1991
  self.assert200(response)
2004
1992
  self.assertLessEqual(len(response.json), 5)
2005
1993
 
@@ -2010,7 +1998,7 @@ class DatasetResourceAPITest(APITestCase):
2010
1998
  """It should suggest mime types"""
2011
1999
  DatasetFactory(resources=[ResourceFactory(mime="application/xhtml+xml")])
2012
2000
 
2013
- response = self.get(url_for("api.suggest_mime"), qs={"q": "xml", "size": "5"})
2001
+ response = self.get(url_for("api.suggest_mime", q="xml", size=5))
2014
2002
  self.assert200(response)
2015
2003
 
2016
2004
  self.assertEqual(len(response.json), 5)
@@ -2019,13 +2007,13 @@ class DatasetResourceAPITest(APITestCase):
2019
2007
  """It should not provide format suggestion if no match"""
2020
2008
  DatasetFactory(resources=[ResourceFactory(mime=faker.word()) for _ in range(3)])
2021
2009
 
2022
- response = self.get(url_for("api.suggest_mime"), qs={"q": "test", "size": "5"})
2010
+ response = self.get(url_for("api.suggest_mime", q="test", size=5))
2023
2011
  self.assert200(response)
2024
2012
  self.assertEqual(len(response.json), 0)
2025
2013
 
2026
2014
  def test_suggest_mime_api_empty(self):
2027
2015
  """It should not provide mime suggestion if no data"""
2028
- response = self.get(url_for("api.suggest_mime"), qs={"q": "test", "size": "5"})
2016
+ response = self.get(url_for("api.suggest_mime", q="test", size=5))
2029
2017
  self.assert200(response)
2030
2018
  self.assertEqual(len(response.json), 0)
2031
2019
 
@@ -2041,7 +2029,7 @@ class DatasetResourceAPITest(APITestCase):
2041
2029
  title="title-test-4", visible=True, metrics={"followers": 10}
2042
2030
  )
2043
2031
 
2044
- response = self.get(url_for("api.suggest_datasets"), qs={"q": "title-test", "size": "5"})
2032
+ response = self.get(url_for("api.suggest_datasets", q="title-test", size=5))
2045
2033
  self.assert200(response)
2046
2034
 
2047
2035
  self.assertLessEqual(len(response.json), 5)
@@ -2064,7 +2052,7 @@ class DatasetResourceAPITest(APITestCase):
2064
2052
  visible=True,
2065
2053
  )
2066
2054
 
2067
- response = self.get(url_for("api.suggest_datasets"), qs={"q": "acronym-test", "size": "5"})
2055
+ response = self.get(url_for("api.suggest_datasets", q="acronym-test", size=5))
2068
2056
  self.assert200(response)
2069
2057
 
2070
2058
  self.assertLessEqual(len(response.json), 5)
@@ -2086,7 +2074,7 @@ class DatasetResourceAPITest(APITestCase):
2086
2074
  resources=[ResourceFactory()],
2087
2075
  )
2088
2076
 
2089
- response = self.get(url_for("api.suggest_datasets"), qs={"q": "title-testé", "size": "5"})
2077
+ response = self.get(url_for("api.suggest_datasets", q="title-testé", size=5))
2090
2078
  self.assert200(response)
2091
2079
 
2092
2080
  self.assertLessEqual(len(response.json), 5)
@@ -2104,13 +2092,13 @@ class DatasetResourceAPITest(APITestCase):
2104
2092
  for i in range(3):
2105
2093
  DatasetFactory(resources=[ResourceFactory()])
2106
2094
 
2107
- response = self.get(url_for("api.suggest_datasets"), qs={"q": "xxxxxx", "size": "5"})
2095
+ response = self.get(url_for("api.suggest_datasets", q="xxxxxx", size=5))
2108
2096
  self.assert200(response)
2109
2097
  self.assertEqual(len(response.json), 0)
2110
2098
 
2111
2099
  def test_suggest_datasets_api_empty(self):
2112
2100
  """It should not provide dataset suggestion if no data"""
2113
- response = self.get(url_for("api.suggest_datasets"), qs={"q": "xxxxxx", "size": "5"})
2101
+ response = self.get(url_for("api.suggest_datasets", q="xxxxxx", size=5))
2114
2102
  self.assert200(response)
2115
2103
  self.assertEqual(len(response.json), 0)
2116
2104
 
@@ -2140,8 +2128,6 @@ class DatasetReferencesAPITest(APITestCase):
2140
2128
 
2141
2129
 
2142
2130
  class DatasetArchivedAPITest(APITestCase):
2143
- modules = []
2144
-
2145
2131
  def test_dataset_api_search_archived(self):
2146
2132
  """It should search datasets from the API, excluding archived ones"""
2147
2133
  DatasetFactory(archived=None)
@@ -2160,8 +2146,6 @@ class DatasetArchivedAPITest(APITestCase):
2160
2146
 
2161
2147
 
2162
2148
  class CommunityResourceAPITest(APITestCase):
2163
- modules = []
2164
-
2165
2149
  def test_community_resource_api_get(self):
2166
2150
  """It should fetch a community resource from the API"""
2167
2151
  community_resource = CommunityResourceFactory()
@@ -2415,10 +2399,7 @@ class ResourcesTypesAPITest(APITestCase):
2415
2399
  self.assertEqual(len(response.json), len(RESOURCE_TYPES))
2416
2400
 
2417
2401
 
2418
- @pytest.mark.usefixtures("clean_db")
2419
- class DatasetSchemasAPITest:
2420
- modules = []
2421
-
2402
+ class DatasetSchemasAPITest(PytestOnlyAPITestCase):
2422
2403
  def test_dataset_schemas_api_list(self, api, rmock, app):
2423
2404
  # Can't use @pytest.mark.options otherwise a request will be
2424
2405
  # made before setting up rmock at module load, resulting in a 404
@@ -2479,10 +2460,7 @@ class DatasetSchemasAPITest:
2479
2460
  )
2480
2461
 
2481
2462
 
2482
- @pytest.mark.usefixtures("clean_db")
2483
- class HarvestMetadataAPITest:
2484
- modules = []
2485
-
2463
+ class HarvestMetadataAPITest(PytestOnlyAPITestCase):
2486
2464
  def test_dataset_with_harvest_metadata(self, api):
2487
2465
  date = datetime(2022, 2, 22, tzinfo=pytz.UTC)
2488
2466
  harvest_metadata = HarvestDatasetMetadata(
@@ -18,8 +18,6 @@ from . import APITestCase
18
18
 
19
19
 
20
20
  class MeAPITest(APITestCase):
21
- modules = []
22
-
23
21
  def test_get_profile(self):
24
22
  """It should fetch my user data on GET"""
25
23
  self.login()
@@ -105,7 +103,7 @@ class MeAPITest(APITestCase):
105
103
  DatasetFactory(owner=user)
106
104
  DatasetFactory(organization=organization)
107
105
 
108
- response = self.get(url_for("api.my_org_datasets"), qs={"q": "foô"})
106
+ response = self.get(url_for("api.my_org_datasets", q="foô"))
109
107
  self.assert200(response)
110
108
  self.assertEqual(len(response.json), len(datasets) + len(org_datasets))
111
109
 
@@ -139,7 +137,7 @@ class MeAPITest(APITestCase):
139
137
  CommunityResourceFactory(owner=user)
140
138
  CommunityResourceFactory(organization=organization)
141
139
 
142
- response = self.get(url_for("api.my_org_community_resources"), qs={"q": "foô"})
140
+ response = self.get(url_for("api.my_org_community_resources", q="foô"))
143
141
  self.assert200(response)
144
142
  self.assertEqual(
145
143
  len(response.json), len(community_resources) + len(org_community_resources)
@@ -171,7 +169,7 @@ class MeAPITest(APITestCase):
171
169
  ReuseFactory(owner=user)
172
170
  ReuseFactory(organization=organization)
173
171
 
174
- response = self.get(url_for("api.my_org_reuses"), qs={"q": "foô"})
172
+ response = self.get(url_for("api.my_org_reuses", q="foô"))
175
173
  self.assert200(response)
176
174
  self.assertEqual(len(response.json), len(reuses) + len(org_reuses))
177
175
 
@@ -221,7 +219,7 @@ class MeAPITest(APITestCase):
221
219
  Discussion.objects.create(subject=DatasetFactory(), title="foô", user=user)
222
220
  Discussion.objects.create(subject=ReuseFactory(), title="foô", user=user)
223
221
 
224
- response = self.get(url_for("api.my_org_discussions"), qs={"q": "foô"})
222
+ response = self.get(url_for("api.my_org_discussions", q="foô"))
225
223
  self.assert200(response)
226
224
  self.assertEqual(len(response.json), len(discussions))
227
225