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.
- udata/api/__init__.py +1 -0
- udata/api_fields.py +10 -4
- udata/app.py +11 -10
- udata/auth/__init__.py +9 -10
- udata/auth/mails.py +137 -45
- udata/auth/views.py +5 -12
- udata/commands/__init__.py +2 -3
- udata/commands/info.py +1 -3
- udata/commands/tests/test_fixtures.py +6 -3
- udata/core/access_type/api.py +18 -0
- udata/core/access_type/constants.py +98 -0
- udata/core/access_type/models.py +44 -0
- udata/core/activity/models.py +1 -1
- udata/core/badges/models.py +1 -1
- udata/core/badges/tasks.py +35 -1
- udata/core/badges/tests/test_commands.py +2 -4
- udata/core/badges/tests/test_model.py +2 -2
- udata/core/badges/tests/test_tasks.py +55 -0
- udata/core/constants.py +1 -0
- udata/core/contact_point/models.py +8 -0
- udata/core/dataservices/api.py +3 -3
- udata/core/dataservices/apiv2.py +3 -1
- udata/core/dataservices/constants.py +0 -29
- udata/core/dataservices/models.py +44 -44
- udata/core/dataservices/rdf.py +2 -1
- udata/core/dataservices/search.py +5 -9
- udata/core/dataservices/tasks.py +33 -0
- udata/core/dataset/api_fields.py +11 -0
- udata/core/dataset/apiv2.py +11 -0
- udata/core/dataset/constants.py +0 -1
- udata/core/dataset/forms.py +29 -0
- udata/core/dataset/models.py +16 -4
- udata/core/dataset/rdf.py +2 -1
- udata/core/dataset/search.py +2 -2
- udata/core/dataset/tasks.py +86 -8
- udata/core/discussions/mails.py +63 -0
- udata/core/discussions/tasks.py +4 -18
- udata/core/metrics/__init__.py +0 -6
- udata/core/organization/api.py +3 -1
- udata/core/organization/mails.py +144 -0
- udata/core/organization/models.py +2 -1
- udata/core/organization/search.py +1 -1
- udata/core/organization/tasks.py +21 -49
- udata/core/pages/tests/test_api.py +0 -2
- udata/core/reuse/api.py +27 -1
- udata/core/reuse/mails.py +21 -0
- udata/core/reuse/models.py +10 -1
- udata/core/reuse/search.py +1 -1
- udata/core/reuse/tasks.py +2 -3
- udata/core/site/models.py +2 -6
- udata/core/spatial/tests/test_api.py +17 -20
- udata/core/spatial/tests/test_models.py +3 -3
- udata/core/user/mails.py +54 -0
- udata/core/user/models.py +2 -3
- udata/core/user/tasks.py +8 -23
- udata/core/user/tests/test_user_model.py +2 -6
- udata/entrypoints.py +0 -5
- udata/features/identicon/tests/test_backends.py +3 -13
- udata/forms/fields.py +3 -3
- udata/forms/widgets.py +2 -2
- udata/frontend/__init__.py +3 -32
- udata/harvest/actions.py +4 -9
- udata/harvest/api.py +5 -14
- udata/harvest/backends/__init__.py +20 -11
- udata/harvest/backends/base.py +2 -2
- udata/harvest/backends/ckan/harvesters.py +2 -1
- udata/harvest/backends/dcat.py +3 -0
- udata/harvest/backends/maaf.py +1 -0
- udata/harvest/commands.py +6 -4
- udata/harvest/forms.py +9 -6
- udata/harvest/tasks.py +3 -5
- 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/dcat/datara--5a26b0f6-0ccf-46ad-ac58-734054b91977.rdf.xml +255 -0
- udata/harvest/tests/dcat/datara--f40c3860-7236-4b30-a141-23b8ae33f7b2.rdf.xml +289 -0
- udata/harvest/tests/factories.py +1 -1
- udata/harvest/tests/test_actions.py +11 -9
- udata/harvest/tests/test_api.py +4 -5
- udata/harvest/tests/test_base_backend.py +5 -4
- udata/harvest/tests/test_dcat_backend.py +50 -19
- 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/mail.py +90 -53
- udata/migrations/2025-01-05-dataservices-fields-changes.py +8 -14
- udata/migrations/2025-10-21-remove-ckan-harvest-modified-at.py +28 -0
- udata/migrations/2025-10-29-harvesters-sources-integrity.py +27 -0
- udata/mongo/taglist_field.py +3 -3
- udata/rdf.py +32 -15
- udata/sentry.py +3 -4
- udata/settings.py +7 -2
- udata/tags.py +5 -5
- udata/tasks.py +3 -3
- udata/templates/mail/message.html +65 -0
- udata/templates/mail/message.txt +16 -0
- 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 +57 -37
- udata/tests/api/test_datasets_api.py +146 -49
- 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 +92 -19
- udata/tests/api/test_security_api.py +124 -0
- 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 +8 -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 +201 -12
- 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 +4 -7
- 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 +150 -114
- 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_rdf.py +19 -15
- udata/tests/test_routing.py +5 -5
- udata/tests/test_storages.py +6 -5
- udata/tests/test_tags.py +2 -4
- 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/user/test_user_tasks.py +3 -5
- udata/tests/workers/test_jobs_commands.py +2 -2
- udata/tests/workers/test_tasks_routing.py +27 -27
- udata/translations/ar/LC_MESSAGES/udata.mo +0 -0
- udata/translations/ar/LC_MESSAGES/udata.po +369 -435
- udata/translations/de/LC_MESSAGES/udata.mo +0 -0
- udata/translations/de/LC_MESSAGES/udata.po +371 -437
- udata/translations/es/LC_MESSAGES/udata.mo +0 -0
- udata/translations/es/LC_MESSAGES/udata.po +369 -435
- udata/translations/fr/LC_MESSAGES/udata.mo +0 -0
- udata/translations/fr/LC_MESSAGES/udata.po +381 -447
- udata/translations/it/LC_MESSAGES/udata.mo +0 -0
- udata/translations/it/LC_MESSAGES/udata.po +371 -437
- udata/translations/pt/LC_MESSAGES/udata.mo +0 -0
- udata/translations/pt/LC_MESSAGES/udata.po +371 -437
- udata/translations/sr/LC_MESSAGES/udata.mo +0 -0
- udata/translations/sr/LC_MESSAGES/udata.po +372 -438
- udata/translations/udata.pot +379 -440
- udata/utils.py +14 -2
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/METADATA +1 -2
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/RECORD +205 -242
- udata/templates/mail/account_deleted.html +0 -5
- udata/templates/mail/account_deleted.txt +0 -6
- udata/templates/mail/account_inactivity.html +0 -40
- udata/templates/mail/account_inactivity.txt +0 -31
- udata/templates/mail/badge_added_association.html +0 -33
- udata/templates/mail/badge_added_association.txt +0 -11
- udata/templates/mail/badge_added_certified.html +0 -33
- udata/templates/mail/badge_added_certified.txt +0 -11
- udata/templates/mail/badge_added_company.html +0 -33
- udata/templates/mail/badge_added_company.txt +0 -11
- udata/templates/mail/badge_added_local_authority.html +0 -33
- udata/templates/mail/badge_added_local_authority.txt +0 -11
- udata/templates/mail/badge_added_public_service.html +0 -33
- udata/templates/mail/badge_added_public_service.txt +0 -11
- udata/templates/mail/discussion_closed.html +0 -47
- udata/templates/mail/discussion_closed.txt +0 -16
- udata/templates/mail/inactive_account_deleted.html +0 -5
- udata/templates/mail/inactive_account_deleted.txt +0 -6
- udata/templates/mail/membership_refused.html +0 -20
- udata/templates/mail/membership_refused.txt +0 -11
- udata/templates/mail/membership_request.html +0 -46
- udata/templates/mail/membership_request.txt +0 -12
- udata/templates/mail/new_discussion.html +0 -44
- udata/templates/mail/new_discussion.txt +0 -15
- udata/templates/mail/new_discussion_comment.html +0 -45
- udata/templates/mail/new_discussion_comment.txt +0 -16
- udata/templates/mail/new_member.html +0 -27
- udata/templates/mail/new_member.txt +0 -11
- udata/templates/mail/new_reuse.html +0 -37
- udata/templates/mail/new_reuse.txt +0 -9
- udata/templates/mail/test.html +0 -6
- udata/templates/mail/test.txt +0 -6
- udata/templates/mail/user_mail_card.html +0 -26
- udata/templates/security/email/base.html +0 -105
- udata/templates/security/email/base.txt +0 -6
- udata/templates/security/email/button.html +0 -3
- udata/templates/security/email/change_notice.html +0 -22
- udata/templates/security/email/change_notice.txt +0 -8
- udata/templates/security/email/confirmation_instructions.html +0 -20
- udata/templates/security/email/confirmation_instructions.txt +0 -7
- udata/templates/security/email/login_instructions.html +0 -19
- udata/templates/security/email/login_instructions.txt +0 -7
- udata/templates/security/email/reset_instructions.html +0 -24
- udata/templates/security/email/reset_instructions.txt +0 -9
- udata/templates/security/email/reset_notice.html +0 -11
- udata/templates/security/email/reset_notice.txt +0 -4
- udata/templates/security/email/welcome.html +0 -24
- udata/templates/security/email/welcome.txt +0 -9
- udata/templates/security/email/welcome_existing.html +0 -32
- udata/templates/security/email/welcome_existing.txt +0 -14
- udata/terms.md +0 -6
- udata/tests/frontend/__init__.py +0 -23
- udata/tests/metrics/conftest.py +0 -15
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/WHEEL +0 -0
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/entry_points.txt +0 -0
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/licenses/LICENSE +0 -0
- {udata-12.0.2.dev15.dist-info → udata-13.0.1.dev21.dist-info}/top_level.txt +0 -0
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),
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -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.
|
|
14
|
-
|
|
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
|
|