udata 12.0.2.dev17__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.
- udata/commands/tests/test_fixtures.py +2 -3
- udata/core/badges/tests/test_commands.py +2 -4
- udata/core/badges/tests/test_model.py +2 -2
- udata/core/pages/tests/test_api.py +0 -2
- udata/core/spatial/tests/test_api.py +17 -20
- udata/core/spatial/tests/test_models.py +3 -3
- udata/core/user/tests/test_user_model.py +2 -6
- udata/features/identicon/tests/test_backends.py +3 -13
- udata/harvest/tests/ckan/test_ckan_backend.py +300 -337
- udata/harvest/tests/ckan/test_ckan_backend_errors.py +94 -99
- udata/harvest/tests/ckan/test_ckan_backend_filters.py +128 -122
- udata/harvest/tests/ckan/test_dkan_backend.py +39 -51
- udata/harvest/tests/test_actions.py +7 -7
- udata/harvest/tests/test_api.py +2 -4
- udata/harvest/tests/test_base_backend.py +3 -4
- udata/harvest/tests/test_dcat_backend.py +4 -6
- udata/harvest/tests/test_models.py +2 -4
- udata/harvest/tests/test_notifications.py +2 -4
- udata/harvest/tests/test_tasks.py +2 -3
- udata/tests/__init__.py +40 -58
- udata/tests/api/__init__.py +87 -2
- udata/tests/api/test_activities_api.py +17 -23
- udata/tests/api/test_auth_api.py +2 -4
- udata/tests/api/test_contact_points.py +48 -54
- udata/tests/api/test_dataservices_api.py +0 -2
- udata/tests/api/test_datasets_api.py +15 -29
- udata/tests/api/test_me_api.py +4 -6
- udata/tests/api/test_organizations_api.py +19 -38
- udata/tests/api/test_reports_api.py +0 -4
- udata/tests/api/test_reuses_api.py +9 -19
- udata/tests/api/test_swagger.py +2 -3
- udata/tests/api/test_tags_api.py +6 -7
- udata/tests/api/test_transfer_api.py +0 -2
- udata/tests/api/test_user_api.py +8 -10
- udata/tests/apiv2/test_datasets.py +0 -4
- udata/tests/apiv2/test_me_api.py +0 -2
- udata/tests/apiv2/test_organizations.py +0 -2
- udata/tests/apiv2/test_swagger.py +2 -3
- udata/tests/apiv2/test_topics.py +0 -2
- udata/tests/cli/test_cli_base.py +14 -12
- udata/tests/cli/test_db_cli.py +51 -54
- udata/tests/contact_point/test_contact_point_models.py +2 -2
- udata/tests/dataservice/test_csv_adapter.py +2 -5
- udata/tests/dataservice/test_dataservice_rdf.py +3 -6
- udata/tests/dataservice/test_dataservice_tasks.py +36 -38
- udata/tests/dataset/test_csv_adapter.py +2 -5
- udata/tests/dataset/test_dataset_actions.py +2 -4
- udata/tests/dataset/test_dataset_commands.py +2 -4
- udata/tests/dataset/test_dataset_events.py +3 -3
- udata/tests/dataset/test_dataset_model.py +6 -7
- udata/tests/dataset/test_dataset_rdf.py +6 -9
- udata/tests/dataset/test_dataset_recommendations.py +2 -2
- udata/tests/dataset/test_dataset_tasks.py +66 -68
- udata/tests/dataset/test_resource_preview.py +39 -48
- udata/tests/dataset/test_transport_tasks.py +2 -2
- udata/tests/features/territories/__init__.py +0 -6
- udata/tests/features/territories/test_territories_api.py +25 -24
- udata/tests/forms/test_current_user_field.py +2 -2
- udata/tests/forms/test_dict_field.py +2 -4
- udata/tests/forms/test_extras_fields.py +2 -3
- udata/tests/forms/test_image_field.py +2 -2
- udata/tests/forms/test_model_field.py +2 -4
- udata/tests/forms/test_publish_as_field.py +2 -4
- udata/tests/forms/test_user_forms.py +26 -29
- udata/tests/frontend/test_auth.py +2 -3
- udata/tests/frontend/test_csv.py +5 -6
- udata/tests/frontend/test_error_handlers.py +2 -3
- udata/tests/frontend/test_hooks.py +5 -7
- udata/tests/frontend/test_markdown.py +3 -4
- udata/tests/helpers.py +2 -7
- udata/tests/metrics/test_metrics.py +52 -48
- udata/tests/metrics/test_tasks.py +154 -150
- udata/tests/organization/test_csv_adapter.py +2 -5
- udata/tests/organization/test_notifications.py +2 -4
- udata/tests/organization/test_organization_model.py +3 -4
- udata/tests/organization/test_organization_rdf.py +2 -8
- udata/tests/plugin.py +6 -110
- udata/tests/reuse/test_reuse_model.py +3 -4
- udata/tests/site/test_site_api.py +0 -2
- udata/tests/site/test_site_csv_exports.py +0 -2
- udata/tests/site/test_site_metrics.py +2 -4
- udata/tests/site/test_site_model.py +2 -2
- udata/tests/site/test_site_rdf.py +3 -6
- udata/tests/test_activity.py +3 -3
- udata/tests/test_api_fields.py +6 -9
- udata/tests/test_cors.py +0 -2
- udata/tests/test_dcat_commands.py +2 -3
- udata/tests/test_discussions.py +2 -7
- udata/tests/test_mail.py +4 -10
- udata/tests/test_migrations.py +413 -419
- udata/tests/test_model.py +10 -11
- udata/tests/test_notifications.py +2 -3
- udata/tests/test_owned.py +3 -3
- udata/tests/test_routing.py +5 -5
- udata/tests/test_storages.py +6 -5
- udata/tests/test_tags.py +2 -1
- udata/tests/test_topics.py +2 -4
- udata/tests/test_transfer.py +4 -5
- udata/tests/topic/test_topic_tasks.py +25 -27
- udata/tests/user/test_user_rdf.py +2 -8
- udata/tests/workers/test_jobs_commands.py +2 -2
- udata/tests/workers/test_tasks_routing.py +27 -27
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/METADATA +1 -1
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/RECORD +108 -110
- udata/tests/frontend/__init__.py +0 -23
- udata/tests/metrics/conftest.py +0 -15
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/WHEEL +0 -0
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/entry_points.txt +0 -0
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/licenses/LICENSE +0 -0
- {udata-12.0.2.dev17.dist-info → udata-12.0.2.dev18.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,7 @@ from udata.core.reuse.constants import REUSE_TOPICS, REUSE_TYPES
|
|
|
13
13
|
from udata.core.reuse.factories import ReuseFactory
|
|
14
14
|
from udata.core.user.factories import AdminFactory, UserFactory
|
|
15
15
|
from udata.models import Follow, Member, Reuse
|
|
16
|
-
from udata.tests.api import APITestCase
|
|
16
|
+
from udata.tests.api import APITestCase, PytestOnlyAPITestCase
|
|
17
17
|
from udata.tests.helpers import (
|
|
18
18
|
assert200,
|
|
19
19
|
assert201,
|
|
@@ -24,19 +24,13 @@ from udata.tests.helpers import (
|
|
|
24
24
|
)
|
|
25
25
|
from udata.utils import faker
|
|
26
26
|
|
|
27
|
-
pytestmark = [
|
|
28
|
-
pytest.mark.usefixtures("clean_db"),
|
|
29
|
-
]
|
|
30
|
-
|
|
31
27
|
|
|
32
28
|
def reuse_in_response(response: TestResponse, reuse: Reuse) -> bool:
|
|
33
29
|
only_reuse = [r for r in response.json["data"] if r["id"] == str(reuse.id)]
|
|
34
30
|
return len(only_reuse) > 0
|
|
35
31
|
|
|
36
32
|
|
|
37
|
-
class ReuseAPITest:
|
|
38
|
-
modules = []
|
|
39
|
-
|
|
33
|
+
class ReuseAPITest(PytestOnlyAPITestCase):
|
|
40
34
|
def test_reuse_api_list(self, api):
|
|
41
35
|
"""It should fetch a reuse list from the API"""
|
|
42
36
|
reuses = ReuseFactory.create_batch(3, visible=True)
|
|
@@ -523,7 +517,7 @@ class ReuseAPITest:
|
|
|
523
517
|
title="arealtestprefix-4", visible=True, metrics={"followers": 10}
|
|
524
518
|
)
|
|
525
519
|
|
|
526
|
-
response = api.get(url_for("api.suggest_reuses"
|
|
520
|
+
response = api.get(url_for("api.suggest_reuses", q="arealtestpref", size=5))
|
|
527
521
|
assert200(response)
|
|
528
522
|
|
|
529
523
|
assert len(response.json) <= 5
|
|
@@ -542,7 +536,7 @@ class ReuseAPITest:
|
|
|
542
536
|
for i in range(4):
|
|
543
537
|
ReuseFactory(title="testé-{0}".format(i) if i % 2 else faker.word(), visible=True)
|
|
544
538
|
|
|
545
|
-
response = api.get(url_for("api.suggest_reuses"
|
|
539
|
+
response = api.get(url_for("api.suggest_reuses", q="testé", size=5))
|
|
546
540
|
assert200(response)
|
|
547
541
|
|
|
548
542
|
assert len(response.json) <= 5
|
|
@@ -559,14 +553,14 @@ class ReuseAPITest:
|
|
|
559
553
|
"""It should not provide reuse suggestion if no match"""
|
|
560
554
|
ReuseFactory.create_batch(3, visible=True)
|
|
561
555
|
|
|
562
|
-
response = api.get(url_for("api.suggest_reuses"
|
|
556
|
+
response = api.get(url_for("api.suggest_reuses", q="xxxxxx", size=5))
|
|
563
557
|
assert200(response)
|
|
564
558
|
assert len(response.json) == 0
|
|
565
559
|
|
|
566
560
|
def test_suggest_reuses_api_empty(self, api):
|
|
567
561
|
"""It should not provide reuse suggestion if no data"""
|
|
568
562
|
# self.init_search()
|
|
569
|
-
response = api.get(url_for("api.suggest_reuses"
|
|
563
|
+
response = api.get(url_for("api.suggest_reuses", q="xxxxxx", size=5))
|
|
570
564
|
assert200(response)
|
|
571
565
|
assert len(response.json) == 0
|
|
572
566
|
|
|
@@ -630,11 +624,9 @@ class ReusesFeedAPItest(APITestCase):
|
|
|
630
624
|
self.assertEqual(author.href, org.url_for())
|
|
631
625
|
|
|
632
626
|
|
|
633
|
-
class ReuseBadgeAPITest:
|
|
634
|
-
modules = []
|
|
635
|
-
|
|
627
|
+
class ReuseBadgeAPITest(PytestOnlyAPITestCase):
|
|
636
628
|
@pytest.fixture(autouse=True)
|
|
637
|
-
def
|
|
629
|
+
def setup_func(self, api):
|
|
638
630
|
# Register at least two badges
|
|
639
631
|
Reuse.__badges__["test-1"] = "Test 1"
|
|
640
632
|
Reuse.__badges__["test-2"] = "Test 2"
|
|
@@ -695,9 +687,7 @@ class ReuseBadgeAPITest:
|
|
|
695
687
|
assert404(response)
|
|
696
688
|
|
|
697
689
|
|
|
698
|
-
class ReuseReferencesAPITest:
|
|
699
|
-
modules = []
|
|
700
|
-
|
|
690
|
+
class ReuseReferencesAPITest(PytestOnlyAPITestCase):
|
|
701
691
|
def test_reuse_types_list(self, api):
|
|
702
692
|
"""It should fetch the reuse types list from the API"""
|
|
703
693
|
response = api.get(url_for("api.reuse_types"))
|
udata/tests/api/test_swagger.py
CHANGED
|
@@ -3,12 +3,11 @@ import json
|
|
|
3
3
|
from flask import url_for
|
|
4
4
|
from flask_restx import schemas
|
|
5
5
|
|
|
6
|
+
from udata.tests.api import PytestOnlyAPITestCase
|
|
6
7
|
from udata.tests.helpers import assert200
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
class SwaggerBlueprintTest:
|
|
10
|
-
modules = []
|
|
11
|
-
|
|
10
|
+
class SwaggerBlueprintTest(PytestOnlyAPITestCase):
|
|
12
11
|
def test_swagger_resource_type(self, api):
|
|
13
12
|
response = api.get(url_for("api.specs"))
|
|
14
13
|
assert200(response)
|
udata/tests/api/test_tags_api.py
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import pytest
|
|
2
1
|
from flask import url_for
|
|
3
2
|
|
|
4
3
|
from udata.core.dataset.factories import DatasetFactory
|
|
5
4
|
from udata.core.reuse.factories import ReuseFactory
|
|
6
5
|
from udata.core.tags.tasks import count_tags
|
|
6
|
+
from udata.tests.api import PytestOnlyAPITestCase
|
|
7
7
|
from udata.tests.helpers import assert200
|
|
8
8
|
from udata.utils import faker
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
class TagsAPITest:
|
|
11
|
+
class TagsAPITest(PytestOnlyAPITestCase):
|
|
13
12
|
def test_suggest_tags_api(self, api):
|
|
14
13
|
"""It should suggest tags"""
|
|
15
14
|
for i in range(3):
|
|
@@ -19,7 +18,7 @@ class TagsAPITest:
|
|
|
19
18
|
|
|
20
19
|
count_tags()
|
|
21
20
|
|
|
22
|
-
response = api.get(url_for("api.suggest_tags"
|
|
21
|
+
response = api.get(url_for("api.suggest_tags", q="tes", size=5))
|
|
23
22
|
assert200(response)
|
|
24
23
|
|
|
25
24
|
assert len(response.json) <= 5
|
|
@@ -39,7 +38,7 @@ class TagsAPITest:
|
|
|
39
38
|
|
|
40
39
|
count_tags()
|
|
41
40
|
|
|
42
|
-
response = api.get(url_for("api.suggest_tags"
|
|
41
|
+
response = api.get(url_for("api.suggest_tags", q="testé", size=5))
|
|
43
42
|
assert200(response)
|
|
44
43
|
|
|
45
44
|
assert len(response.json) <= 5
|
|
@@ -59,12 +58,12 @@ class TagsAPITest:
|
|
|
59
58
|
|
|
60
59
|
count_tags()
|
|
61
60
|
|
|
62
|
-
response = api.get(url_for("api.suggest_tags"
|
|
61
|
+
response = api.get(url_for("api.suggest_tags", q="bbbb", size=5))
|
|
63
62
|
assert200(response)
|
|
64
63
|
assert len(response.json) == 0
|
|
65
64
|
|
|
66
65
|
def test_suggest_tags_api_empty(self, api):
|
|
67
66
|
"""It should not provide tag suggestion if no data"""
|
|
68
|
-
response = api.get(url_for("api.suggest_tags"
|
|
67
|
+
response = api.get(url_for("api.suggest_tags", q="bbbb", size=5))
|
|
69
68
|
assert200(response)
|
|
70
69
|
assert len(response.json) == 0
|
udata/tests/api/test_user_api.py
CHANGED
|
@@ -11,8 +11,6 @@ from . import APITestCase
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class UserAPITest(APITestCase):
|
|
14
|
-
modules = []
|
|
15
|
-
|
|
16
14
|
def test_follow_user(self):
|
|
17
15
|
"""It should follow an user on POST"""
|
|
18
16
|
user = self.login()
|
|
@@ -65,7 +63,7 @@ class UserAPITest(APITestCase):
|
|
|
65
63
|
for i in range(4):
|
|
66
64
|
UserFactory(first_name="first-name-test-{0}".format(i) if i % 2 else faker.word())
|
|
67
65
|
|
|
68
|
-
response = self.get(url_for("api.suggest_users"
|
|
66
|
+
response = self.get(url_for("api.suggest_users", q="first-name-test", size=5))
|
|
69
67
|
self.assert200(response)
|
|
70
68
|
|
|
71
69
|
self.assertLessEqual(len(response.json), 5)
|
|
@@ -84,7 +82,7 @@ class UserAPITest(APITestCase):
|
|
|
84
82
|
for i in range(4):
|
|
85
83
|
UserFactory(last_name="last-name-test-{0}".format(i) if i % 2 else faker.word())
|
|
86
84
|
|
|
87
|
-
response = self.get(url_for("api.suggest_users"
|
|
85
|
+
response = self.get(url_for("api.suggest_users", q="last-name-test", size=5))
|
|
88
86
|
self.assert200(response)
|
|
89
87
|
|
|
90
88
|
self.assertLessEqual(len(response.json), 5)
|
|
@@ -102,7 +100,7 @@ class UserAPITest(APITestCase):
|
|
|
102
100
|
for i in range(4):
|
|
103
101
|
UserFactory(last_name="last-name-testé-{0}".format(i) if i % 2 else faker.word())
|
|
104
102
|
|
|
105
|
-
response = self.get(url_for("api.suggest_users"
|
|
103
|
+
response = self.get(url_for("api.suggest_users", q="last-name-testé", size=5))
|
|
106
104
|
self.assert200(response)
|
|
107
105
|
|
|
108
106
|
self.assertLessEqual(len(response.json), 5)
|
|
@@ -119,13 +117,13 @@ class UserAPITest(APITestCase):
|
|
|
119
117
|
"""It should not provide user suggestion if no match"""
|
|
120
118
|
UserFactory.create_batch(3)
|
|
121
119
|
|
|
122
|
-
response = self.get(url_for("api.suggest_users"
|
|
120
|
+
response = self.get(url_for("api.suggest_users", q="xxxxxx", size=5))
|
|
123
121
|
self.assert200(response)
|
|
124
122
|
self.assertEqual(len(response.json), 0)
|
|
125
123
|
|
|
126
124
|
def test_suggest_users_api_empty(self):
|
|
127
125
|
"""It should not provide user suggestion if no data"""
|
|
128
|
-
response = self.get(url_for("api.suggest_users"
|
|
126
|
+
response = self.get(url_for("api.suggest_users", q="xxxxxx", size=5))
|
|
129
127
|
self.assert200(response)
|
|
130
128
|
self.assertEqual(len(response.json), 0)
|
|
131
129
|
|
|
@@ -133,7 +131,7 @@ class UserAPITest(APITestCase):
|
|
|
133
131
|
"""It should suggest users without deduplicating homonyms"""
|
|
134
132
|
UserFactory.create_batch(2, first_name="test", last_name="homonym")
|
|
135
133
|
|
|
136
|
-
response = self.get(url_for("api.suggest_users"
|
|
134
|
+
response = self.get(url_for("api.suggest_users", q="homonym", size=5))
|
|
137
135
|
self.assert200(response)
|
|
138
136
|
|
|
139
137
|
self.assertEqual(len(response.json), 2)
|
|
@@ -144,11 +142,11 @@ class UserAPITest(APITestCase):
|
|
|
144
142
|
|
|
145
143
|
def test_suggest_users_api_size_validation(self):
|
|
146
144
|
"""It should validate that the size parameter is between 1 and 20."""
|
|
147
|
-
response = self.get(url_for("api.suggest_users"
|
|
145
|
+
response = self.get(url_for("api.suggest_users", q="foobar", size=0))
|
|
148
146
|
self.assert400(response)
|
|
149
147
|
self.assertIn("between 1 and 20", response.json["errors"]["size"])
|
|
150
148
|
|
|
151
|
-
response = self.get(url_for("api.suggest_users"
|
|
149
|
+
response = self.get(url_for("api.suggest_users", q="foobar", size=21))
|
|
152
150
|
|
|
153
151
|
self.assert400(response)
|
|
154
152
|
self.assertIn("between 1 and 20", response.json["errors"]["size"])
|
|
@@ -367,8 +367,6 @@ class DatasetResourceAPIV2Test(APITestCase):
|
|
|
367
367
|
|
|
368
368
|
|
|
369
369
|
class DatasetExtrasAPITest(APITestCase):
|
|
370
|
-
modules = None
|
|
371
|
-
|
|
372
370
|
def setUp(self):
|
|
373
371
|
self.login()
|
|
374
372
|
self.dataset = DatasetFactory(owner=self.user)
|
|
@@ -503,8 +501,6 @@ class DatasetExtrasAPITest(APITestCase):
|
|
|
503
501
|
|
|
504
502
|
|
|
505
503
|
class DatasetResourceExtrasAPITest(APITestCase):
|
|
506
|
-
modules = None
|
|
507
|
-
|
|
508
504
|
def setUp(self):
|
|
509
505
|
self.login()
|
|
510
506
|
self.dataset = DatasetFactory(owner=self.user)
|
udata/tests/apiv2/test_me_api.py
CHANGED
|
@@ -3,12 +3,11 @@ import json
|
|
|
3
3
|
from flask import url_for
|
|
4
4
|
from flask_restx import schemas
|
|
5
5
|
|
|
6
|
+
from udata.tests.api import PytestOnlyAPITestCase
|
|
6
7
|
from udata.tests.helpers import assert200
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
class SwaggerBlueprintTest:
|
|
10
|
-
modules = []
|
|
11
|
-
|
|
10
|
+
class SwaggerBlueprintTest(PytestOnlyAPITestCase):
|
|
12
11
|
def test_swagger_resource_type(self, api):
|
|
13
12
|
response = api.get(url_for("apiv2.specs"))
|
|
14
13
|
assert200(response)
|
udata/tests/apiv2/test_topics.py
CHANGED
udata/tests/cli/test_cli_base.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
"""Should display help without errors"""
|
|
3
|
-
cli()
|
|
4
|
-
cli("-?")
|
|
5
|
-
cli("-h")
|
|
6
|
-
cli("--help")
|
|
1
|
+
from udata.tests import PytestOnlyTestCase
|
|
7
2
|
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
class CliBaseTest(PytestOnlyTestCase):
|
|
5
|
+
def test_cli_help(self, cli):
|
|
6
|
+
"""Should display help without errors"""
|
|
7
|
+
cli()
|
|
8
|
+
cli("-?")
|
|
9
|
+
cli("-h")
|
|
10
|
+
cli("--help")
|
|
12
11
|
|
|
12
|
+
def test_cli_log_and_printing(self, cli):
|
|
13
|
+
"""Should properly log and print"""
|
|
14
|
+
cli("test log")
|
|
13
15
|
|
|
14
|
-
def test_cli_version(cli):
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
def test_cli_version(self, cli):
|
|
17
|
+
"""Should display version without errors"""
|
|
18
|
+
cli("--version")
|
udata/tests/cli/test_db_cli.py
CHANGED
|
@@ -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(
|
|
11
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def test_unrecord_with_filename_without_extension(cli, migrations):
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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),
|
|
@@ -16,13 +16,11 @@ from udata.rdf import (
|
|
|
16
16
|
HVD_LEGISLATION,
|
|
17
17
|
TAG_TO_EU_HVD_CATEGORIES,
|
|
18
18
|
)
|
|
19
|
+
from udata.tests.api import PytestOnlyAPITestCase
|
|
19
20
|
from udata.tests.helpers import assert200, assert_redirects
|
|
20
21
|
|
|
21
|
-
pytestmark = pytest.mark.usefixtures("app")
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
@pytest.mark.frontend
|
|
25
|
-
class DataserviceToRdfTest:
|
|
23
|
+
class DataserviceToRdfTest(PytestOnlyAPITestCase):
|
|
26
24
|
def test_minimal(self):
|
|
27
25
|
dataservice = DataserviceFactory.build() # Does not have an URL
|
|
28
26
|
d = dataservice_to_rdf(dataservice)
|
|
@@ -83,8 +81,7 @@ class DataserviceToRdfTest:
|
|
|
83
81
|
assert distrib.value(DCATAP.applicableLegislation).identifier == URIRef(HVD_LEGISLATION)
|
|
84
82
|
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
class DataserviceRdfViewsTest:
|
|
84
|
+
class DataserviceRdfViewsTest(PytestOnlyAPITestCase):
|
|
88
85
|
def test_rdf_default_to_jsonld(self, client):
|
|
89
86
|
dataservice = DataserviceFactory()
|
|
90
87
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
class DatasetCommandTest:
|
|
7
|
+
class DatasetCommandTest(PytestOnlyDBTestCase):
|
|
10
8
|
def test_dataset_archive_one(self, cli):
|
|
11
9
|
dataset = DatasetFactory()
|
|
12
10
|
|