udata 9.1.2.dev30355__py2.py3-none-any.whl → 9.1.2.dev30454__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- tasks/__init__.py +109 -107
- tasks/helpers.py +18 -18
- udata/__init__.py +4 -4
- udata/admin/views.py +5 -5
- udata/api/__init__.py +111 -134
- udata/api/commands.py +45 -37
- udata/api/errors.py +5 -4
- udata/api/fields.py +23 -21
- udata/api/oauth2.py +55 -74
- udata/api/parsers.py +15 -15
- udata/api/signals.py +1 -1
- udata/api_fields.py +137 -89
- udata/app.py +58 -55
- udata/assets.py +5 -5
- udata/auth/__init__.py +37 -26
- udata/auth/forms.py +23 -15
- udata/auth/helpers.py +1 -1
- udata/auth/mails.py +3 -3
- udata/auth/password_validation.py +19 -15
- udata/auth/views.py +94 -68
- udata/commands/__init__.py +71 -69
- udata/commands/cache.py +7 -7
- udata/commands/db.py +201 -140
- udata/commands/dcat.py +36 -30
- udata/commands/fixtures.py +100 -84
- udata/commands/images.py +21 -20
- udata/commands/info.py +17 -20
- udata/commands/init.py +10 -10
- udata/commands/purge.py +12 -13
- udata/commands/serve.py +41 -29
- udata/commands/static.py +16 -18
- udata/commands/test.py +20 -20
- udata/commands/tests/fixtures.py +26 -24
- udata/commands/worker.py +31 -33
- udata/core/__init__.py +12 -12
- udata/core/activity/__init__.py +0 -1
- udata/core/activity/api.py +59 -49
- udata/core/activity/models.py +28 -26
- udata/core/activity/signals.py +1 -1
- udata/core/activity/tasks.py +16 -10
- udata/core/badges/api.py +6 -6
- udata/core/badges/commands.py +14 -13
- udata/core/badges/fields.py +8 -5
- udata/core/badges/forms.py +7 -4
- udata/core/badges/models.py +16 -31
- udata/core/badges/permissions.py +1 -3
- udata/core/badges/signals.py +2 -2
- udata/core/badges/tasks.py +3 -2
- udata/core/badges/tests/test_commands.py +10 -10
- udata/core/badges/tests/test_model.py +24 -31
- udata/core/contact_point/api.py +19 -18
- udata/core/contact_point/api_fields.py +21 -14
- udata/core/contact_point/factories.py +2 -2
- udata/core/contact_point/forms.py +7 -6
- udata/core/contact_point/models.py +3 -5
- udata/core/dataservices/api.py +26 -21
- udata/core/dataservices/factories.py +13 -11
- udata/core/dataservices/models.py +35 -40
- udata/core/dataservices/permissions.py +4 -4
- udata/core/dataservices/rdf.py +40 -17
- udata/core/dataservices/tasks.py +4 -3
- udata/core/dataset/actions.py +10 -10
- udata/core/dataset/activities.py +21 -23
- udata/core/dataset/api.py +321 -298
- udata/core/dataset/api_fields.py +443 -271
- udata/core/dataset/apiv2.py +305 -229
- udata/core/dataset/commands.py +38 -36
- udata/core/dataset/constants.py +61 -54
- udata/core/dataset/csv.py +70 -74
- udata/core/dataset/events.py +39 -32
- udata/core/dataset/exceptions.py +8 -4
- udata/core/dataset/factories.py +57 -65
- udata/core/dataset/forms.py +87 -63
- udata/core/dataset/models.py +336 -280
- udata/core/dataset/permissions.py +9 -6
- udata/core/dataset/preview.py +15 -17
- udata/core/dataset/rdf.py +156 -122
- udata/core/dataset/search.py +92 -77
- udata/core/dataset/signals.py +1 -1
- udata/core/dataset/tasks.py +63 -54
- udata/core/discussions/actions.py +5 -5
- udata/core/discussions/api.py +124 -120
- udata/core/discussions/factories.py +2 -2
- udata/core/discussions/forms.py +9 -7
- udata/core/discussions/metrics.py +1 -3
- udata/core/discussions/models.py +25 -24
- udata/core/discussions/notifications.py +18 -14
- udata/core/discussions/permissions.py +3 -3
- udata/core/discussions/signals.py +4 -4
- udata/core/discussions/tasks.py +24 -28
- udata/core/followers/api.py +32 -33
- udata/core/followers/models.py +9 -9
- udata/core/followers/signals.py +3 -3
- udata/core/jobs/actions.py +7 -7
- udata/core/jobs/api.py +99 -92
- udata/core/jobs/commands.py +48 -49
- udata/core/jobs/forms.py +11 -11
- udata/core/jobs/models.py +6 -6
- udata/core/metrics/__init__.py +2 -2
- udata/core/metrics/commands.py +34 -30
- udata/core/metrics/models.py +2 -4
- udata/core/metrics/signals.py +1 -1
- udata/core/metrics/tasks.py +3 -3
- udata/core/organization/activities.py +12 -15
- udata/core/organization/api.py +167 -174
- udata/core/organization/api_fields.py +183 -124
- udata/core/organization/apiv2.py +32 -32
- udata/core/organization/commands.py +20 -22
- udata/core/organization/constants.py +11 -11
- udata/core/organization/csv.py +17 -15
- udata/core/organization/factories.py +8 -11
- udata/core/organization/forms.py +32 -26
- udata/core/organization/metrics.py +2 -1
- udata/core/organization/models.py +87 -67
- udata/core/organization/notifications.py +18 -14
- udata/core/organization/permissions.py +10 -11
- udata/core/organization/rdf.py +14 -14
- udata/core/organization/search.py +30 -28
- udata/core/organization/signals.py +7 -7
- udata/core/organization/tasks.py +42 -61
- udata/core/owned.py +38 -27
- udata/core/post/api.py +82 -81
- udata/core/post/constants.py +8 -5
- udata/core/post/factories.py +4 -4
- udata/core/post/forms.py +13 -14
- udata/core/post/models.py +20 -22
- udata/core/post/tests/test_api.py +30 -32
- udata/core/reports/api.py +8 -7
- udata/core/reports/constants.py +1 -3
- udata/core/reports/models.py +10 -10
- udata/core/reuse/activities.py +15 -19
- udata/core/reuse/api.py +123 -126
- udata/core/reuse/api_fields.py +120 -85
- udata/core/reuse/apiv2.py +11 -10
- udata/core/reuse/constants.py +23 -23
- udata/core/reuse/csv.py +18 -18
- udata/core/reuse/factories.py +5 -9
- udata/core/reuse/forms.py +24 -21
- udata/core/reuse/models.py +55 -51
- udata/core/reuse/permissions.py +2 -2
- udata/core/reuse/search.py +49 -46
- udata/core/reuse/signals.py +1 -1
- udata/core/reuse/tasks.py +4 -5
- udata/core/site/api.py +47 -50
- udata/core/site/factories.py +2 -2
- udata/core/site/forms.py +4 -5
- udata/core/site/models.py +94 -63
- udata/core/site/rdf.py +14 -14
- udata/core/spam/api.py +16 -9
- udata/core/spam/constants.py +4 -4
- udata/core/spam/fields.py +13 -7
- udata/core/spam/models.py +27 -20
- udata/core/spam/signals.py +1 -1
- udata/core/spam/tests/test_spam.py +6 -5
- udata/core/spatial/api.py +72 -80
- udata/core/spatial/api_fields.py +73 -58
- udata/core/spatial/commands.py +67 -64
- udata/core/spatial/constants.py +3 -3
- udata/core/spatial/factories.py +37 -54
- udata/core/spatial/forms.py +27 -26
- udata/core/spatial/geoids.py +17 -17
- udata/core/spatial/models.py +43 -47
- udata/core/spatial/tasks.py +2 -1
- udata/core/spatial/tests/test_api.py +115 -130
- udata/core/spatial/tests/test_fields.py +74 -77
- udata/core/spatial/tests/test_geoid.py +22 -22
- udata/core/spatial/tests/test_models.py +5 -7
- udata/core/spatial/translations.py +16 -16
- udata/core/storages/__init__.py +16 -18
- udata/core/storages/api.py +66 -64
- udata/core/storages/tasks.py +7 -7
- udata/core/storages/utils.py +15 -15
- udata/core/storages/views.py +5 -6
- udata/core/tags/api.py +17 -14
- udata/core/tags/csv.py +4 -4
- udata/core/tags/models.py +8 -5
- udata/core/tags/tasks.py +11 -13
- udata/core/tags/views.py +4 -4
- udata/core/topic/api.py +84 -73
- udata/core/topic/apiv2.py +157 -127
- udata/core/topic/factories.py +3 -4
- udata/core/topic/forms.py +12 -14
- udata/core/topic/models.py +14 -19
- udata/core/topic/parsers.py +26 -26
- udata/core/user/activities.py +30 -29
- udata/core/user/api.py +151 -152
- udata/core/user/api_fields.py +132 -100
- udata/core/user/apiv2.py +7 -7
- udata/core/user/commands.py +38 -38
- udata/core/user/factories.py +8 -9
- udata/core/user/forms.py +14 -11
- udata/core/user/metrics.py +2 -2
- udata/core/user/models.py +68 -69
- udata/core/user/permissions.py +4 -5
- udata/core/user/rdf.py +7 -8
- udata/core/user/tasks.py +2 -2
- udata/core/user/tests/test_user_model.py +24 -16
- udata/cors.py +99 -0
- udata/db/tasks.py +2 -1
- udata/entrypoints.py +35 -31
- udata/errors.py +2 -1
- udata/event/values.py +6 -6
- udata/factories.py +2 -2
- udata/features/identicon/api.py +5 -6
- udata/features/identicon/backends.py +48 -55
- udata/features/identicon/tests/test_backends.py +4 -5
- udata/features/notifications/__init__.py +0 -1
- udata/features/notifications/actions.py +9 -9
- udata/features/notifications/api.py +17 -13
- udata/features/territories/__init__.py +12 -10
- udata/features/territories/api.py +14 -15
- udata/features/territories/models.py +23 -28
- udata/features/transfer/actions.py +8 -11
- udata/features/transfer/api.py +84 -77
- udata/features/transfer/factories.py +2 -1
- udata/features/transfer/models.py +11 -12
- udata/features/transfer/notifications.py +19 -15
- udata/features/transfer/permissions.py +5 -5
- udata/forms/__init__.py +5 -2
- udata/forms/fields.py +164 -172
- udata/forms/validators.py +19 -22
- udata/forms/widgets.py +9 -13
- udata/frontend/__init__.py +31 -26
- udata/frontend/csv.py +68 -58
- udata/frontend/markdown.py +40 -44
- udata/harvest/actions.py +89 -77
- udata/harvest/api.py +294 -238
- udata/harvest/backends/__init__.py +4 -4
- udata/harvest/backends/base.py +128 -111
- udata/harvest/backends/dcat.py +80 -66
- udata/harvest/commands.py +56 -60
- udata/harvest/csv.py +8 -8
- udata/harvest/exceptions.py +6 -3
- udata/harvest/filters.py +24 -23
- udata/harvest/forms.py +27 -28
- udata/harvest/models.py +88 -80
- udata/harvest/notifications.py +15 -10
- udata/harvest/signals.py +13 -13
- udata/harvest/tasks.py +11 -10
- udata/harvest/tests/factories.py +23 -24
- udata/harvest/tests/test_actions.py +136 -166
- udata/harvest/tests/test_api.py +220 -214
- udata/harvest/tests/test_base_backend.py +117 -112
- udata/harvest/tests/test_dcat_backend.py +380 -308
- udata/harvest/tests/test_filters.py +33 -22
- udata/harvest/tests/test_models.py +11 -14
- udata/harvest/tests/test_notifications.py +6 -7
- udata/harvest/tests/test_tasks.py +7 -6
- udata/i18n.py +237 -78
- udata/linkchecker/backends.py +5 -11
- udata/linkchecker/checker.py +23 -22
- udata/linkchecker/commands.py +4 -6
- udata/linkchecker/models.py +6 -6
- udata/linkchecker/tasks.py +18 -20
- udata/mail.py +21 -21
- udata/migrations/2020-07-24-remove-s-from-scope-oauth.py +9 -8
- udata/migrations/2020-08-24-add-fs-filename.py +9 -8
- udata/migrations/2020-09-28-update-reuses-datasets-metrics.py +5 -4
- udata/migrations/2020-10-16-migrate-ods-resources.py +9 -10
- udata/migrations/2021-04-08-update-schema-with-new-structure.py +8 -7
- udata/migrations/2021-05-27-fix-default-schema-name.py +7 -6
- udata/migrations/2021-07-05-remove-unused-badges.py +17 -15
- udata/migrations/2021-07-07-update-schema-for-community-resources.py +7 -6
- udata/migrations/2021-08-17-follow-integrity.py +5 -4
- udata/migrations/2021-08-17-harvest-integrity.py +13 -12
- udata/migrations/2021-08-17-oauth2client-integrity.py +5 -4
- udata/migrations/2021-08-17-transfer-integrity.py +5 -4
- udata/migrations/2021-08-17-users-integrity.py +9 -8
- udata/migrations/2021-12-14-reuse-topics.py +7 -6
- udata/migrations/2022-04-21-improve-extension-detection.py +8 -7
- udata/migrations/2022-09-22-clean-inactive-harvest-datasets.py +16 -14
- udata/migrations/2022-10-10-add-fs_uniquifier-to-user-model.py +6 -6
- udata/migrations/2022-10-10-migrate-harvest-extras.py +36 -26
- udata/migrations/2023-02-08-rename-internal-dates.py +46 -28
- udata/migrations/2024-01-29-fix-reuse-and-dataset-with-private-None.py +10 -8
- udata/migrations/2024-03-22-migrate-activity-kwargs-to-extras.py +6 -4
- udata/migrations/2024-06-11-fix-reuse-datasets-references.py +7 -6
- udata/migrations/__init__.py +123 -105
- udata/models/__init__.py +4 -4
- udata/mongo/__init__.py +13 -11
- udata/mongo/badges_field.py +3 -2
- udata/mongo/datetime_fields.py +13 -12
- udata/mongo/document.py +17 -16
- udata/mongo/engine.py +15 -16
- udata/mongo/errors.py +2 -1
- udata/mongo/extras_fields.py +30 -20
- udata/mongo/queryset.py +12 -12
- udata/mongo/slug_fields.py +38 -28
- udata/mongo/taglist_field.py +1 -2
- udata/mongo/url_field.py +5 -5
- udata/mongo/uuid_fields.py +4 -3
- udata/notifications/__init__.py +1 -1
- udata/notifications/mattermost.py +10 -9
- udata/rdf.py +167 -188
- udata/routing.py +40 -45
- udata/search/__init__.py +18 -19
- udata/search/adapter.py +17 -16
- udata/search/commands.py +44 -51
- udata/search/fields.py +13 -20
- udata/search/query.py +23 -18
- udata/search/result.py +9 -10
- udata/sentry.py +21 -19
- udata/settings.py +262 -198
- udata/sitemap.py +8 -6
- udata/storage/s3.py +20 -13
- udata/tags.py +4 -5
- udata/tasks.py +43 -42
- udata/tests/__init__.py +9 -6
- udata/tests/api/__init__.py +8 -6
- udata/tests/api/test_auth_api.py +395 -321
- udata/tests/api/test_base_api.py +33 -35
- udata/tests/api/test_contact_points.py +7 -9
- udata/tests/api/test_dataservices_api.py +211 -158
- udata/tests/api/test_datasets_api.py +823 -812
- udata/tests/api/test_follow_api.py +13 -15
- udata/tests/api/test_me_api.py +95 -112
- udata/tests/api/test_organizations_api.py +301 -339
- udata/tests/api/test_reports_api.py +35 -25
- udata/tests/api/test_reuses_api.py +134 -139
- udata/tests/api/test_swagger.py +5 -5
- udata/tests/api/test_tags_api.py +18 -25
- udata/tests/api/test_topics_api.py +94 -94
- udata/tests/api/test_transfer_api.py +53 -48
- udata/tests/api/test_user_api.py +128 -141
- udata/tests/apiv2/test_datasets.py +290 -198
- udata/tests/apiv2/test_me_api.py +10 -11
- udata/tests/apiv2/test_organizations.py +56 -74
- udata/tests/apiv2/test_swagger.py +5 -5
- udata/tests/apiv2/test_topics.py +69 -87
- udata/tests/cli/test_cli_base.py +8 -8
- udata/tests/cli/test_db_cli.py +21 -19
- udata/tests/dataservice/test_dataservice_tasks.py +8 -12
- udata/tests/dataset/test_csv_adapter.py +44 -35
- udata/tests/dataset/test_dataset_actions.py +2 -3
- udata/tests/dataset/test_dataset_commands.py +7 -8
- udata/tests/dataset/test_dataset_events.py +36 -29
- udata/tests/dataset/test_dataset_model.py +224 -217
- udata/tests/dataset/test_dataset_rdf.py +142 -131
- udata/tests/dataset/test_dataset_tasks.py +15 -15
- udata/tests/dataset/test_resource_preview.py +10 -13
- udata/tests/features/territories/__init__.py +9 -13
- udata/tests/features/territories/test_territories_api.py +71 -91
- udata/tests/forms/test_basic_fields.py +7 -7
- udata/tests/forms/test_current_user_field.py +39 -66
- udata/tests/forms/test_daterange_field.py +31 -39
- udata/tests/forms/test_dict_field.py +28 -26
- udata/tests/forms/test_extras_fields.py +102 -76
- udata/tests/forms/test_form_field.py +8 -8
- udata/tests/forms/test_image_field.py +33 -26
- udata/tests/forms/test_model_field.py +134 -123
- udata/tests/forms/test_model_list_field.py +7 -7
- udata/tests/forms/test_nested_model_list_field.py +117 -79
- udata/tests/forms/test_publish_as_field.py +36 -65
- udata/tests/forms/test_reference_field.py +34 -53
- udata/tests/forms/test_user_forms.py +23 -21
- udata/tests/forms/test_uuid_field.py +6 -10
- udata/tests/frontend/__init__.py +9 -6
- udata/tests/frontend/test_auth.py +7 -6
- udata/tests/frontend/test_csv.py +81 -96
- udata/tests/frontend/test_hooks.py +43 -43
- udata/tests/frontend/test_markdown.py +211 -191
- udata/tests/helpers.py +32 -37
- udata/tests/models.py +2 -2
- udata/tests/organization/test_csv_adapter.py +21 -16
- udata/tests/organization/test_notifications.py +11 -18
- udata/tests/organization/test_organization_model.py +13 -13
- udata/tests/organization/test_organization_rdf.py +29 -22
- udata/tests/organization/test_organization_tasks.py +16 -17
- udata/tests/plugin.py +79 -73
- udata/tests/reuse/test_reuse_model.py +21 -21
- udata/tests/reuse/test_reuse_task.py +11 -13
- udata/tests/search/__init__.py +11 -12
- udata/tests/search/test_adapter.py +60 -70
- udata/tests/search/test_query.py +16 -16
- udata/tests/search/test_results.py +10 -7
- udata/tests/site/test_site_api.py +11 -16
- udata/tests/site/test_site_metrics.py +20 -30
- udata/tests/site/test_site_model.py +4 -5
- udata/tests/site/test_site_rdf.py +94 -78
- udata/tests/test_activity.py +17 -17
- udata/tests/test_cors.py +62 -0
- udata/tests/test_discussions.py +292 -299
- udata/tests/test_i18n.py +37 -40
- udata/tests/test_linkchecker.py +91 -85
- udata/tests/test_mail.py +13 -17
- udata/tests/test_migrations.py +219 -180
- udata/tests/test_model.py +164 -157
- udata/tests/test_notifications.py +17 -17
- udata/tests/test_owned.py +14 -14
- udata/tests/test_rdf.py +25 -23
- udata/tests/test_routing.py +89 -93
- udata/tests/test_storages.py +137 -128
- udata/tests/test_tags.py +44 -46
- udata/tests/test_topics.py +7 -7
- udata/tests/test_transfer.py +42 -49
- udata/tests/test_uris.py +160 -161
- udata/tests/test_utils.py +79 -71
- udata/tests/user/test_user_rdf.py +5 -9
- udata/tests/workers/test_jobs_commands.py +57 -58
- udata/tests/workers/test_tasks_routing.py +23 -29
- udata/tests/workers/test_workers_api.py +125 -131
- udata/tests/workers/test_workers_helpers.py +6 -6
- udata/tracking.py +4 -6
- udata/uris.py +45 -46
- udata/utils.py +68 -66
- udata/wsgi.py +1 -1
- {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30454.dist-info}/METADATA +7 -3
- udata-9.1.2.dev30454.dist-info/RECORD +706 -0
- udata-9.1.2.dev30355.dist-info/RECORD +0 -704
- {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30454.dist-info}/LICENSE +0 -0
- {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30454.dist-info}/WHEEL +0 -0
- {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30454.dist-info}/entry_points.txt +0 -0
- {udata-9.1.2.dev30355.dist-info → udata-9.1.2.dev30454.dist-info}/top_level.txt +0 -0
udata/tests/api/test_tags_api.py
CHANGED
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
import pytest
|
|
2
|
-
|
|
3
2
|
from flask import url_for
|
|
4
3
|
|
|
5
4
|
from udata.core.dataset.factories import DatasetFactory
|
|
6
5
|
from udata.core.reuse.factories import ReuseFactory
|
|
7
6
|
from udata.core.tags.tasks import count_tags
|
|
8
|
-
from udata.utils import faker
|
|
9
7
|
from udata.tests.helpers import assert200
|
|
8
|
+
from udata.utils import faker
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@pytest.mark.frontend
|
|
13
12
|
class TagsAPITest:
|
|
14
13
|
def test_suggest_tags_api(self, api):
|
|
15
|
-
|
|
14
|
+
"""It should suggest tags"""
|
|
16
15
|
for i in range(3):
|
|
17
|
-
tags = [faker.word(), faker.word(),
|
|
18
|
-
'test-{0}'.format(i)]
|
|
16
|
+
tags = [faker.word(), faker.word(), "test", "test-{0}".format(i)]
|
|
19
17
|
ReuseFactory(tags=tags, visible=True)
|
|
20
18
|
DatasetFactory(tags=tags, visible=True)
|
|
21
19
|
|
|
22
20
|
count_tags()
|
|
23
21
|
|
|
24
|
-
response = api.get(url_for(
|
|
25
|
-
qs={'q': 'tes', 'size': '5'})
|
|
22
|
+
response = api.get(url_for("api.suggest_tags"), qs={"q": "tes", "size": "5"})
|
|
26
23
|
assert200(response)
|
|
27
24
|
|
|
28
25
|
assert len(response.json) <= 5
|
|
29
26
|
assert len(response.json) > 1
|
|
30
|
-
assert response.json[0][
|
|
27
|
+
assert response.json[0]["text"] == "test"
|
|
31
28
|
|
|
32
29
|
for suggestion in response.json:
|
|
33
|
-
assert
|
|
34
|
-
assert
|
|
30
|
+
assert "text" in suggestion
|
|
31
|
+
assert "tes" in suggestion["text"]
|
|
35
32
|
|
|
36
33
|
def test_suggest_tags_api_with_unicode(self, api):
|
|
37
|
-
|
|
34
|
+
"""It should suggest tags"""
|
|
38
35
|
for i in range(3):
|
|
39
|
-
tags = [faker.word(), faker.word(),
|
|
40
|
-
'testé-{0}'.format(i)]
|
|
36
|
+
tags = [faker.word(), faker.word(), "testé", "testé-{0}".format(i)]
|
|
41
37
|
ReuseFactory(tags=tags, visible=True)
|
|
42
38
|
DatasetFactory(tags=tags, visible=True)
|
|
43
39
|
|
|
44
40
|
count_tags()
|
|
45
41
|
|
|
46
|
-
response = api.get(url_for(
|
|
47
|
-
qs={'q': 'testé', 'size': '5'})
|
|
42
|
+
response = api.get(url_for("api.suggest_tags"), qs={"q": "testé", "size": "5"})
|
|
48
43
|
assert200(response)
|
|
49
44
|
|
|
50
45
|
assert len(response.json) <= 5
|
|
51
46
|
assert len(response.json) > 1
|
|
52
|
-
assert response.json[0][
|
|
47
|
+
assert response.json[0]["text"] == "teste"
|
|
53
48
|
|
|
54
49
|
for suggestion in response.json:
|
|
55
|
-
assert
|
|
56
|
-
assert
|
|
50
|
+
assert "text" in suggestion
|
|
51
|
+
assert "teste" in suggestion["text"]
|
|
57
52
|
|
|
58
53
|
def test_suggest_tags_api_no_match(self, api):
|
|
59
|
-
|
|
54
|
+
"""It should not provide tag suggestion if no match"""
|
|
60
55
|
for i in range(3):
|
|
61
|
-
tags = [
|
|
56
|
+
tags = ["aaaa", "aaaa-{0}".format(i)]
|
|
62
57
|
ReuseFactory(tags=tags, visible=True)
|
|
63
58
|
DatasetFactory(tags=tags, visible=True)
|
|
64
59
|
|
|
65
60
|
count_tags()
|
|
66
61
|
|
|
67
|
-
response = api.get(url_for(
|
|
68
|
-
qs={'q': 'bbbb', 'size': '5'})
|
|
62
|
+
response = api.get(url_for("api.suggest_tags"), qs={"q": "bbbb", "size": "5"})
|
|
69
63
|
assert200(response)
|
|
70
64
|
assert len(response.json) is 0
|
|
71
65
|
|
|
72
66
|
def test_suggest_tags_api_empty(self, api):
|
|
73
|
-
|
|
74
|
-
response = api.get(url_for(
|
|
75
|
-
qs={'q': 'bbbb', 'size': '5'})
|
|
67
|
+
"""It should not provide tag suggestion if no data"""
|
|
68
|
+
response = api.get(url_for("api.suggest_tags"), qs={"q": "bbbb", "size": "5"})
|
|
76
69
|
assert200(response)
|
|
77
70
|
assert len(response.json) is 0
|
|
@@ -6,7 +6,7 @@ from udata.core.spatial.models import spatial_granularities
|
|
|
6
6
|
from udata.core.topic.factories import TopicFactory
|
|
7
7
|
from udata.core.topic.models import Topic
|
|
8
8
|
from udata.core.user.factories import UserFactory
|
|
9
|
-
from udata.models import
|
|
9
|
+
from udata.models import Discussion, Member
|
|
10
10
|
from udata.tests.api.test_datasets_api import SAMPLE_GEOM
|
|
11
11
|
from udata.tests.features.territories import create_geozones_fixtures
|
|
12
12
|
|
|
@@ -17,124 +17,121 @@ class TopicsAPITest(APITestCase):
|
|
|
17
17
|
modules = []
|
|
18
18
|
|
|
19
19
|
def test_topic_api_list(self):
|
|
20
|
-
|
|
20
|
+
"""It should fetch a topic list from the API"""
|
|
21
21
|
owner = UserFactory()
|
|
22
22
|
org = OrganizationFactory()
|
|
23
23
|
paca, _, _ = create_geozones_fixtures()
|
|
24
24
|
|
|
25
|
-
tag_topic = TopicFactory(tags=[
|
|
26
|
-
name_topic = TopicFactory(name=
|
|
25
|
+
tag_topic = TopicFactory(tags=["energy"])
|
|
26
|
+
name_topic = TopicFactory(name="topic-for-query")
|
|
27
27
|
private_topic = TopicFactory(private=True)
|
|
28
28
|
geozone_topic = TopicFactory(spatial=SpatialCoverageFactory(zones=[paca.id]))
|
|
29
|
-
granularity_topic = TopicFactory(
|
|
30
|
-
spatial=SpatialCoverageFactory(granularity='country')
|
|
31
|
-
)
|
|
29
|
+
granularity_topic = TopicFactory(spatial=SpatialCoverageFactory(granularity="country"))
|
|
32
30
|
owner_topic = TopicFactory(owner=owner)
|
|
33
31
|
org_topic = TopicFactory(organization=org)
|
|
34
32
|
|
|
35
|
-
response = self.get(url_for(
|
|
33
|
+
response = self.get(url_for("api.topics"))
|
|
36
34
|
self.assert200(response)
|
|
37
|
-
self.assertEqual(len(response.json[
|
|
35
|
+
self.assertEqual(len(response.json["data"]), 6)
|
|
38
36
|
|
|
39
|
-
response = self.get(url_for(
|
|
37
|
+
response = self.get(url_for("api.topics", q="topic-for"))
|
|
40
38
|
self.assert200(response)
|
|
41
|
-
self.assertEqual(len(response.json[
|
|
42
|
-
self.assertEqual(response.json[
|
|
39
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
40
|
+
self.assertEqual(response.json["data"][0]["id"], str(name_topic.id))
|
|
43
41
|
|
|
44
|
-
response = self.get(url_for(
|
|
42
|
+
response = self.get(url_for("api.topics", tag="energy"))
|
|
45
43
|
self.assert200(response)
|
|
46
|
-
self.assertEqual(len(response.json[
|
|
47
|
-
self.assertEqual(response.json[
|
|
48
|
-
datasets = response.json[
|
|
44
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
45
|
+
self.assertEqual(response.json["data"][0]["id"], str(tag_topic.id))
|
|
46
|
+
datasets = response.json["data"][0]["datasets"]
|
|
49
47
|
self.assertEqual(len(datasets), 3)
|
|
50
48
|
for dataset, expected in zip(datasets, [d.fetch() for d in tag_topic.datasets]):
|
|
51
|
-
self.assertEqual(dataset[
|
|
52
|
-
self.assertEqual(dataset[
|
|
53
|
-
self.assertIsNotNone(dataset[
|
|
54
|
-
self.assertIsNotNone(dataset[
|
|
55
|
-
reuses = response.json[
|
|
49
|
+
self.assertEqual(dataset["id"], str(expected.id))
|
|
50
|
+
self.assertEqual(dataset["title"], str(expected.title))
|
|
51
|
+
self.assertIsNotNone(dataset["page"])
|
|
52
|
+
self.assertIsNotNone(dataset["uri"])
|
|
53
|
+
reuses = response.json["data"][0]["reuses"]
|
|
56
54
|
for reuse, expected in zip(reuses, [r.fetch() for r in tag_topic.reuses]):
|
|
57
|
-
self.assertEqual(reuse[
|
|
58
|
-
self.assertEqual(reuse[
|
|
59
|
-
self.assertIsNotNone(reuse[
|
|
60
|
-
self.assertIsNotNone(reuse[
|
|
55
|
+
self.assertEqual(reuse["id"], str(expected.id))
|
|
56
|
+
self.assertEqual(reuse["title"], str(expected.title))
|
|
57
|
+
self.assertIsNotNone(reuse["page"])
|
|
58
|
+
self.assertIsNotNone(reuse["uri"])
|
|
61
59
|
self.assertEqual(len(reuses), 3)
|
|
62
60
|
|
|
63
|
-
response = self.get(url_for(
|
|
61
|
+
response = self.get(url_for("api.topics", include_private="true"))
|
|
64
62
|
self.assert200(response)
|
|
65
|
-
self.assertEqual(len(response.json[
|
|
66
|
-
self.assertIn(str(private_topic.id), [t[
|
|
63
|
+
self.assertEqual(len(response.json["data"]), 7)
|
|
64
|
+
self.assertIn(str(private_topic.id), [t["id"] for t in response.json["data"]])
|
|
67
65
|
|
|
68
|
-
response = self.get(url_for(
|
|
66
|
+
response = self.get(url_for("api.topics", geozone=paca.id))
|
|
69
67
|
self.assert200(response)
|
|
70
|
-
self.assertEqual(len(response.json[
|
|
71
|
-
self.assertIn(str(geozone_topic.id), [t[
|
|
68
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
69
|
+
self.assertIn(str(geozone_topic.id), [t["id"] for t in response.json["data"]])
|
|
72
70
|
|
|
73
|
-
response = self.get(url_for(
|
|
71
|
+
response = self.get(url_for("api.topics", granularity="country"))
|
|
74
72
|
self.assert200(response)
|
|
75
|
-
self.assertEqual(len(response.json[
|
|
76
|
-
self.assertIn(str(granularity_topic.id), [t[
|
|
73
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
74
|
+
self.assertIn(str(granularity_topic.id), [t["id"] for t in response.json["data"]])
|
|
77
75
|
|
|
78
|
-
response = self.get(url_for(
|
|
76
|
+
response = self.get(url_for("api.topics", owner=owner.id))
|
|
79
77
|
self.assert200(response)
|
|
80
|
-
self.assertEqual(len(response.json[
|
|
81
|
-
self.assertIn(str(owner_topic.id), [t[
|
|
78
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
79
|
+
self.assertIn(str(owner_topic.id), [t["id"] for t in response.json["data"]])
|
|
82
80
|
|
|
83
|
-
response = self.get(url_for(
|
|
81
|
+
response = self.get(url_for("api.topics", organization=org.id))
|
|
84
82
|
self.assert200(response)
|
|
85
|
-
self.assertEqual(len(response.json[
|
|
86
|
-
self.assertIn(str(org_topic.id), [t[
|
|
87
|
-
|
|
83
|
+
self.assertEqual(len(response.json["data"]), 1)
|
|
84
|
+
self.assertIn(str(org_topic.id), [t["id"] for t in response.json["data"]])
|
|
88
85
|
|
|
89
86
|
def test_topic_api_get(self):
|
|
90
|
-
|
|
87
|
+
"""It should fetch a topic from the API"""
|
|
91
88
|
topic = TopicFactory()
|
|
92
|
-
response = self.get(url_for(
|
|
89
|
+
response = self.get(url_for("api.topic", topic=topic))
|
|
93
90
|
self.assert200(response)
|
|
94
91
|
|
|
95
92
|
data = response.json
|
|
96
|
-
self.assertIn(
|
|
93
|
+
self.assertIn("spatial", data)
|
|
97
94
|
|
|
98
|
-
for dataset, expected in zip(data[
|
|
99
|
-
self.assertEqual(dataset[
|
|
100
|
-
self.assertEqual(dataset[
|
|
101
|
-
self.assertIsNotNone(dataset[
|
|
102
|
-
self.assertIsNotNone(dataset[
|
|
95
|
+
for dataset, expected in zip(data["datasets"], [d.fetch() for d in topic.datasets]):
|
|
96
|
+
self.assertEqual(dataset["id"], str(expected.id))
|
|
97
|
+
self.assertEqual(dataset["title"], str(expected.title))
|
|
98
|
+
self.assertIsNotNone(dataset["page"])
|
|
99
|
+
self.assertIsNotNone(dataset["uri"])
|
|
103
100
|
|
|
104
|
-
for reuse, expected in zip(data[
|
|
105
|
-
self.assertEqual(reuse[
|
|
106
|
-
self.assertEqual(reuse[
|
|
107
|
-
self.assertIsNotNone(reuse[
|
|
108
|
-
self.assertIsNotNone(reuse[
|
|
101
|
+
for reuse, expected in zip(data["reuses"], [r.fetch() for r in topic.reuses]):
|
|
102
|
+
self.assertEqual(reuse["id"], str(expected.id))
|
|
103
|
+
self.assertEqual(reuse["title"], str(expected.title))
|
|
104
|
+
self.assertIsNotNone(reuse["page"])
|
|
105
|
+
self.assertIsNotNone(reuse["uri"])
|
|
109
106
|
|
|
110
|
-
self.assertIsNotNone(data.get(
|
|
111
|
-
self.assertIsNotNone(data.get(
|
|
107
|
+
self.assertIsNotNone(data.get("created_at"))
|
|
108
|
+
self.assertIsNotNone(data.get("last_modified"))
|
|
112
109
|
|
|
113
110
|
def test_topic_api_create(self):
|
|
114
|
-
|
|
111
|
+
"""It should create a topic from the API"""
|
|
115
112
|
data = TopicFactory.as_dict()
|
|
116
|
-
data[
|
|
117
|
-
data[
|
|
113
|
+
data["datasets"] = [str(d.id) for d in data["datasets"]]
|
|
114
|
+
data["reuses"] = [str(r.id) for r in data["reuses"]]
|
|
118
115
|
self.login()
|
|
119
|
-
response = self.post(url_for(
|
|
116
|
+
response = self.post(url_for("api.topics"), data)
|
|
120
117
|
self.assert201(response)
|
|
121
118
|
self.assertEqual(Topic.objects.count(), 1)
|
|
122
119
|
topic = Topic.objects.first()
|
|
123
|
-
for dataset, expected in zip(topic.datasets, data[
|
|
120
|
+
for dataset, expected in zip(topic.datasets, data["datasets"]):
|
|
124
121
|
self.assertEqual(str(dataset.id), expected)
|
|
125
|
-
for reuse, expected in zip(topic.reuses, data[
|
|
122
|
+
for reuse, expected in zip(topic.reuses, data["reuses"]):
|
|
126
123
|
self.assertEqual(str(reuse.id), expected)
|
|
127
124
|
|
|
128
125
|
def test_topic_api_create_as_org(self):
|
|
129
|
-
|
|
126
|
+
"""It should create a topic as organization from the API"""
|
|
130
127
|
data = TopicFactory.as_dict()
|
|
131
|
-
data[
|
|
132
|
-
data[
|
|
128
|
+
data["datasets"] = [str(d.id) for d in data["datasets"]]
|
|
129
|
+
data["reuses"] = [str(r.id) for r in data["reuses"]]
|
|
133
130
|
user = self.login()
|
|
134
|
-
member = Member(user=user, role=
|
|
131
|
+
member = Member(user=user, role="editor")
|
|
135
132
|
org = OrganizationFactory(members=[member])
|
|
136
|
-
data[
|
|
137
|
-
response = self.post(url_for(
|
|
133
|
+
data["organization"] = str(org.id)
|
|
134
|
+
response = self.post(url_for("api.topics"), data)
|
|
138
135
|
self.assert201(response)
|
|
139
136
|
self.assertEqual(Topic.objects.count(), 1)
|
|
140
137
|
|
|
@@ -146,15 +143,15 @@ class TopicsAPITest(APITestCase):
|
|
|
146
143
|
paca, _, _ = create_geozones_fixtures()
|
|
147
144
|
granularity = spatial_granularities[0][0]
|
|
148
145
|
data = TopicFactory.as_dict()
|
|
149
|
-
data[
|
|
150
|
-
data[
|
|
151
|
-
data[
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
data["datasets"] = [str(d.id) for d in data["datasets"]]
|
|
147
|
+
data["reuses"] = [str(r.id) for r in data["reuses"]]
|
|
148
|
+
data["spatial"] = {
|
|
149
|
+
"zones": [paca.id],
|
|
150
|
+
"geom": SAMPLE_GEOM,
|
|
151
|
+
"granularity": granularity,
|
|
155
152
|
}
|
|
156
153
|
self.login()
|
|
157
|
-
response = self.post(url_for(
|
|
154
|
+
response = self.post(url_for("api.topics"), data)
|
|
158
155
|
self.assert201(response)
|
|
159
156
|
self.assertEqual(Topic.objects.count(), 1)
|
|
160
157
|
topic = Topic.objects.first()
|
|
@@ -163,58 +160,61 @@ class TopicsAPITest(APITestCase):
|
|
|
163
160
|
self.assertEqual(topic.spatial.granularity, granularity)
|
|
164
161
|
|
|
165
162
|
def test_topic_api_update(self):
|
|
166
|
-
|
|
163
|
+
"""It should update a topic from the API"""
|
|
167
164
|
owner = self.login()
|
|
168
165
|
topic = TopicFactory(owner=owner)
|
|
169
166
|
data = topic.to_dict()
|
|
170
|
-
data[
|
|
171
|
-
response = self.put(url_for(
|
|
167
|
+
data["description"] = "new description"
|
|
168
|
+
response = self.put(url_for("api.topic", topic=topic), data)
|
|
172
169
|
self.assert200(response)
|
|
173
170
|
self.assertEqual(Topic.objects.count(), 1)
|
|
174
171
|
topic = Topic.objects.first()
|
|
175
|
-
self.assertEqual(topic.description,
|
|
172
|
+
self.assertEqual(topic.description, "new description")
|
|
176
173
|
self.assertGreater(topic.last_modified, topic.created_at)
|
|
177
174
|
|
|
178
175
|
def test_topic_api_update_perm(self):
|
|
179
|
-
|
|
176
|
+
"""It should not update a topic from the API"""
|
|
180
177
|
owner = UserFactory()
|
|
181
178
|
topic = TopicFactory(owner=owner)
|
|
182
179
|
user = self.login()
|
|
183
180
|
data = topic.to_dict()
|
|
184
|
-
data[
|
|
185
|
-
response = self.put(url_for(
|
|
181
|
+
data["owner"] = user.to_dict()
|
|
182
|
+
response = self.put(url_for("api.topic", topic=topic), data)
|
|
186
183
|
self.assert403(response)
|
|
187
184
|
|
|
188
185
|
def test_topic_api_delete(self):
|
|
189
|
-
|
|
186
|
+
"""It should delete a topic from the API"""
|
|
190
187
|
owner = self.login()
|
|
191
188
|
topic = TopicFactory(owner=owner)
|
|
192
189
|
|
|
193
190
|
with self.api_user():
|
|
194
|
-
response = self.post(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
response = self.post(
|
|
192
|
+
url_for("api.discussions"),
|
|
193
|
+
{
|
|
194
|
+
"title": "test title",
|
|
195
|
+
"comment": "bla bla",
|
|
196
|
+
"subject": {
|
|
197
|
+
"class": "Topic",
|
|
198
|
+
"id": topic.id,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
)
|
|
202
202
|
self.assert201(response)
|
|
203
203
|
|
|
204
204
|
discussions = Discussion.objects(subject=topic)
|
|
205
205
|
self.assertEqual(len(discussions), 1)
|
|
206
206
|
|
|
207
207
|
with self.api_user():
|
|
208
|
-
response = self.delete(url_for(
|
|
208
|
+
response = self.delete(url_for("api.topic", topic=topic))
|
|
209
209
|
self.assertStatus(response, 204)
|
|
210
210
|
|
|
211
211
|
self.assertEqual(Topic.objects.count(), 0)
|
|
212
212
|
self.assertEqual(Discussion.objects.count(), 0)
|
|
213
213
|
|
|
214
214
|
def test_topic_api_delete_perm(self):
|
|
215
|
-
|
|
215
|
+
"""It should not delete a topic from the API"""
|
|
216
216
|
owner = UserFactory()
|
|
217
217
|
topic = TopicFactory(owner=owner)
|
|
218
218
|
with self.api_user():
|
|
219
|
-
response = self.delete(url_for(
|
|
219
|
+
response = self.delete(url_for("api.topic", topic=topic))
|
|
220
220
|
self.assertStatus(response, 403)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
from bson import ObjectId
|
|
2
|
-
from mock import patch
|
|
3
|
-
|
|
4
2
|
from flask import url_for
|
|
3
|
+
from mock import patch
|
|
5
4
|
|
|
6
5
|
from udata.core.dataset.factories import DatasetFactory
|
|
7
|
-
from udata.features.transfer.factories import TransferFactory
|
|
8
6
|
from udata.core.user.factories import UserFactory
|
|
7
|
+
from udata.features.transfer.factories import TransferFactory
|
|
9
8
|
from udata.utils import faker
|
|
10
9
|
|
|
11
10
|
from . import APITestCase
|
|
@@ -14,7 +13,7 @@ from . import APITestCase
|
|
|
14
13
|
class TransferAPITest(APITestCase):
|
|
15
14
|
modules = []
|
|
16
15
|
|
|
17
|
-
@patch(
|
|
16
|
+
@patch("udata.features.transfer.api.request_transfer")
|
|
18
17
|
def test_request_dataset_transfer(self, action):
|
|
19
18
|
user = self.login()
|
|
20
19
|
recipient = UserFactory()
|
|
@@ -22,23 +21,23 @@ class TransferAPITest(APITestCase):
|
|
|
22
21
|
comment = faker.sentence()
|
|
23
22
|
|
|
24
23
|
action.return_value = TransferFactory(
|
|
25
|
-
owner=user,
|
|
26
|
-
recipient=recipient,
|
|
27
|
-
subject=dataset,
|
|
28
|
-
comment=comment
|
|
24
|
+
owner=user, recipient=recipient, subject=dataset, comment=comment
|
|
29
25
|
)
|
|
30
26
|
|
|
31
|
-
response = self.post(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
response = self.post(
|
|
28
|
+
url_for("api.transfers"),
|
|
29
|
+
{
|
|
30
|
+
"subject": {
|
|
31
|
+
"class": "Dataset",
|
|
32
|
+
"id": str(dataset.id),
|
|
33
|
+
},
|
|
34
|
+
"recipient": {
|
|
35
|
+
"class": "User",
|
|
36
|
+
"id": str(recipient.id),
|
|
37
|
+
},
|
|
38
|
+
"comment": comment,
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
})
|
|
40
|
+
)
|
|
42
41
|
|
|
43
42
|
self.assert201(response)
|
|
44
43
|
|
|
@@ -46,60 +45,66 @@ class TransferAPITest(APITestCase):
|
|
|
46
45
|
|
|
47
46
|
data = response.json
|
|
48
47
|
|
|
49
|
-
self.assertEqual(data[
|
|
50
|
-
self.assertEqual(data[
|
|
48
|
+
self.assertEqual(data["recipient"]["id"], str(recipient.id))
|
|
49
|
+
self.assertEqual(data["recipient"]["class"], "User")
|
|
51
50
|
|
|
52
|
-
self.assertEqual(data[
|
|
53
|
-
self.assertEqual(data[
|
|
51
|
+
self.assertEqual(data["subject"]["id"], str(dataset.id))
|
|
52
|
+
self.assertEqual(data["subject"]["class"], "Dataset")
|
|
54
53
|
|
|
55
|
-
self.assertEqual(data[
|
|
56
|
-
self.assertEqual(data[
|
|
54
|
+
self.assertEqual(data["owner"]["id"], str(user.id))
|
|
55
|
+
self.assertEqual(data["owner"]["class"], "User")
|
|
57
56
|
|
|
58
|
-
self.assertEqual(data[
|
|
59
|
-
self.assertEqual(data[
|
|
57
|
+
self.assertEqual(data["comment"], comment)
|
|
58
|
+
self.assertEqual(data["status"], "pending")
|
|
60
59
|
|
|
61
60
|
def test_400_on_bad_subject(self):
|
|
62
61
|
user = self.login()
|
|
63
62
|
recipient = UserFactory()
|
|
64
63
|
comment = faker.sentence()
|
|
65
64
|
|
|
66
|
-
response = self.post(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
response = self.post(
|
|
66
|
+
url_for("api.transfers"),
|
|
67
|
+
{
|
|
68
|
+
"subject": {
|
|
69
|
+
"class": "Dataset",
|
|
70
|
+
"id": str(ObjectId()),
|
|
71
|
+
},
|
|
72
|
+
"recipient": {
|
|
73
|
+
"class": "User",
|
|
74
|
+
"id": str(recipient.id),
|
|
75
|
+
},
|
|
76
|
+
"comment": comment,
|
|
74
77
|
},
|
|
75
|
-
|
|
76
|
-
})
|
|
78
|
+
)
|
|
77
79
|
|
|
78
80
|
self.assert400(response)
|
|
79
81
|
|
|
80
82
|
data = response.json
|
|
81
83
|
|
|
82
|
-
self.assertIn(
|
|
84
|
+
self.assertIn("subject", data["errors"])
|
|
83
85
|
|
|
84
86
|
def test_400_on_bad_recipient(self):
|
|
85
87
|
user = self.login()
|
|
86
88
|
dataset = DatasetFactory(owner=user)
|
|
87
89
|
comment = faker.sentence()
|
|
88
90
|
|
|
89
|
-
response = self.post(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
response = self.post(
|
|
92
|
+
url_for("api.transfers"),
|
|
93
|
+
{
|
|
94
|
+
"subject": {
|
|
95
|
+
"class": "Dataset",
|
|
96
|
+
"id": str(dataset.id),
|
|
97
|
+
},
|
|
98
|
+
"recipient": {
|
|
99
|
+
"class": "User",
|
|
100
|
+
"id": str(ObjectId()),
|
|
101
|
+
},
|
|
102
|
+
"comment": comment,
|
|
93
103
|
},
|
|
94
|
-
|
|
95
|
-
'class': 'User',
|
|
96
|
-
'id': str(ObjectId()),
|
|
97
|
-
},
|
|
98
|
-
'comment': comment
|
|
99
|
-
})
|
|
104
|
+
)
|
|
100
105
|
|
|
101
106
|
self.assert400(response)
|
|
102
107
|
|
|
103
108
|
data = response.json
|
|
104
109
|
|
|
105
|
-
self.assertIn(
|
|
110
|
+
self.assertIn("recipient", data["errors"])
|