udata 7.0.6.dev28263__py2.py3-none-any.whl → 7.0.6.dev28345__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.

Files changed (33) hide show
  1. udata/commands/dcat.py +7 -4
  2. udata/core/dataset/factories.py +2 -4
  3. udata/core/dataset/models.py +2 -5
  4. udata/core/dataset/search.py +0 -1
  5. udata/core/spatial/tests/test_api.py +7 -10
  6. udata/core/topic/factories.py +2 -2
  7. udata/harvest/backends/dcat.py +128 -24
  8. udata/harvest/tests/csw_dcat/XSLT.xml +4298 -0
  9. udata/harvest/tests/csw_dcat/geonetwork-iso-page-1.xml +1291 -0
  10. udata/harvest/tests/csw_dcat/geonetwork-iso-page-3.xml +1139 -0
  11. udata/harvest/tests/csw_dcat/geonetwork-iso-page-5.xml +1266 -0
  12. udata/harvest/tests/test_dcat_backend.py +63 -5
  13. udata/rdf.py +1 -0
  14. udata/search/__init__.py +2 -2
  15. udata/tests/api/test_datasets_api.py +43 -44
  16. udata/tests/api/test_me_api.py +13 -14
  17. udata/tests/dataset/test_dataset_actions.py +2 -2
  18. udata/tests/dataset/test_dataset_commands.py +3 -3
  19. udata/tests/organization/test_organization_model.py +3 -3
  20. udata/tests/organization/test_organization_rdf.py +3 -3
  21. udata/tests/reuse/test_reuse_model.py +2 -2
  22. udata/tests/search/test_adapter.py +12 -12
  23. udata/tests/search/test_results.py +4 -4
  24. udata/tests/site/test_site_api.py +3 -3
  25. udata/tests/site/test_site_metrics.py +3 -3
  26. udata/tests/site/test_site_rdf.py +6 -6
  27. udata/tests/test_transfer.py +18 -17
  28. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/METADATA +3 -1
  29. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/RECORD +33 -29
  30. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/entry_points.txt +1 -0
  31. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/LICENSE +0 -0
  32. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/WHEEL +0 -0
  33. {udata-7.0.6.dev28263.dist-info → udata-7.0.6.dev28345.dist-info}/top_level.txt +0 -0
@@ -1,21 +1,22 @@
1
+ from datetime import date
1
2
  import logging
2
3
  import os
3
- from flask import current_app
4
+ import re
4
5
 
5
6
  import pytest
6
7
 
7
- from datetime import date
8
8
  import boto3
9
+ from flask import current_app
9
10
  import xml.etree.ElementTree as ET
10
- from udata.harvest.models import HarvestJob
11
11
 
12
+ from udata.harvest.models import HarvestJob
12
13
  from udata.models import Dataset
13
14
  from udata.core.organization.factories import OrganizationFactory
14
15
  from udata.core.dataset.factories import LicenseFactory, ResourceSchemaMockData
15
16
  from udata.storage.s3 import get_from_json
16
17
 
17
18
  from .factories import HarvestSourceFactory
18
- from ..backends.dcat import URIS_TO_REPLACE
19
+ from ..backends.dcat import URIS_TO_REPLACE, CswIso19139DcatBackend
19
20
  from .. import actions
20
21
 
21
22
  log = logging.getLogger(__name__)
@@ -629,7 +630,7 @@ class DcatBackendTest:
629
630
 
630
631
 
631
632
  @pytest.mark.usefixtures('clean_db')
632
- @pytest.mark.options(PLUGINS=['csw-dcat'])
633
+ @pytest.mark.options(PLUGINS=['csw'])
633
634
  class CswDcatBackendTest:
634
635
 
635
636
  def test_geonetworkv4(self, rmock):
@@ -677,3 +678,60 @@ class CswDcatBackendTest:
677
678
 
678
679
  assert 'User-Agent' in get_mock.last_request.headers
679
680
  assert get_mock.last_request.headers['User-Agent'] == 'uData/0.1 csw-dcat'
681
+
682
+
683
+ @pytest.mark.usefixtures('clean_db')
684
+ @pytest.mark.options(PLUGINS=['csw'])
685
+ class CswIso19139DcatBackendTest:
686
+
687
+ def test_geo2france(self, rmock):
688
+
689
+ with open(os.path.join(CSW_DCAT_FILES_DIR, "XSLT.xml"), "r") as f:
690
+ xslt = f.read()
691
+ url = mock_csw_pagination(rmock, 'geonetwork/srv/eng/csw.rdf', 'geonetwork-iso-page-{}.xml')
692
+ rmock.get(CswIso19139DcatBackend.XSL_URL, text=xslt)
693
+ org = OrganizationFactory()
694
+ source = HarvestSourceFactory(backend='csw-iso-19139',
695
+ url=url,
696
+ organization=org)
697
+
698
+ actions.run(source.slug)
699
+
700
+ source.reload()
701
+
702
+ job = source.get_last_job()
703
+ assert len(job.items) == 6
704
+
705
+ datasets = {d.harvest.dct_identifier: d for d in Dataset.objects}
706
+
707
+ assert len(datasets) == 6
708
+
709
+ # First dataset
710
+ # dataset identifier is gmd:RS_Identifier > gmd:codeSpace + gmd:code
711
+ dataset = datasets['http://catalogue.geo-ide.developpement-durable.gouv.fr/fr-120066022-orphan-residentifier-140d31c6-643d-42a9-85df-2737a118e144']
712
+ assert dataset.title == "Plan local d'urbanisme de la commune de Cartigny"
713
+ assert dataset.description == "Le présent standard de données COVADIS concerne les documents de plans locaux d'urbanisme (PLU) et les plans d'occupation des sols (POS qui valent PLU)."
714
+ assert set(dataset.tags) == set([
715
+ 'amenagement-urbanisme-zonages-planification', 'cartigny',
716
+ 'document-durbanisme', 'donnees-ouvertes', 'plu', 'usage-des-sols'
717
+ ])
718
+ assert dataset.harvest.created_at.date() == date(2017, 10, 7)
719
+ assert dataset.spatial.geom == {'type': 'MultiPolygon', 'coordinates':
720
+ [[[[3.28133559, 50.48188019], [1.31279111, 50.48188019], [1.31279111, 49.38547516], [3.28133559, 49.38547516], [3.28133559, 50.48188019]]]]
721
+ }
722
+ assert dataset.contact_point.name == 'DDTM 80 (Direction Départementale des Territoires et de la Mer de la Somme)'
723
+ assert dataset.contact_point.email == 'ddtm-sap-bsig@somme.gouv.fr'
724
+
725
+ # License is not properly mapped in XSLT conversion
726
+ assert dataset.license is None
727
+
728
+ # Distributions don't get properly mapped to distribution with this XSLT if missing CI_OnLineFunctionCode.
729
+ # A CI_OnLineFunctionCode was added explicitely on one of the Online Resources.
730
+ # (See mapping at: https://semiceu.github.io/GeoDCAT-AP/releases/2.0.0/#resource-locator---on-line-resource)
731
+ assert len(dataset.resources) == 1
732
+ resource = dataset.resources[0]
733
+ assert resource.title == 'Téléchargement direct du lot et des documents associés'
734
+ assert resource.url == 'http://atom.geo-ide.developpement-durable.gouv.fr/atomArchive/GetResource?id=fr-120066022-ldd-cab63273-b3ae-4e8a-ae1c-6192e45faa94&datasetAggregate=true'
735
+
736
+ # Sadly resource format is parsed as a blank node. Format parsing should be improved.
737
+ assert re.match(r'n[0-9a-f]{32}', resource.format)
udata/rdf.py CHANGED
@@ -76,6 +76,7 @@ ACCEPTED_MIME_TYPES = {
76
76
  'application/ld+json': 'json-ld',
77
77
  'application/json': 'json-ld',
78
78
  'application/trig': 'trig',
79
+ 'text/xml': 'xml',
79
80
  # Available but not activated
80
81
  # 'application/n-quads': 'nquads',
81
82
  # 'text/xml': 'trix',
udata/search/__init__.py CHANGED
@@ -24,7 +24,7 @@ def reindex(classname, id):
24
24
  document = adapter_class.serialize(obj)
25
25
  if adapter_class.is_indexable(obj):
26
26
  log.info('Indexing %s (%s)', model.__name__, obj.id)
27
- url = f"{current_app.config['SEARCH_SERVICE_API_URL']}{adapter_class.search_url}/index"
27
+ url = f"{current_app.config['SEARCH_SERVICE_API_URL']}{adapter_class.search_url}index"
28
28
  try:
29
29
  payload = {
30
30
  'document': document
@@ -35,7 +35,7 @@ def reindex(classname, id):
35
35
  log.exception('Unable to index/unindex %s "%s"', model.__name__, str(obj.id))
36
36
  else:
37
37
  log.info('Unindexing %s (%s)', model.__name__, obj.id)
38
- url = f"{current_app.config['SEARCH_SERVICE_API_URL']}{adapter_class.search_url}/{str(obj.id)}/unindex"
38
+ url = f"{current_app.config['SEARCH_SERVICE_API_URL']}{adapter_class.search_url}{str(obj.id)}/unindex"
39
39
  try:
40
40
  r = requests.delete(url)
41
41
  if r.status_code == 404:
@@ -17,7 +17,7 @@ from udata.core.dataset.api_fields import (dataset_harvest_fields,
17
17
  from udata.core.dataset.factories import (CommunityResourceFactory,
18
18
  DatasetFactory, LicenseFactory,
19
19
  ResourceFactory, ResourceSchemaMockData,
20
- VisibleDatasetFactory)
20
+ HiddenDatasetFactory)
21
21
  from udata.core.dataset.models import (HarvestDatasetMetadata,
22
22
  HarvestResourceMetadata, ResourceMixin)
23
23
  from udata.core.organization.factories import OrganizationFactory
@@ -44,12 +44,13 @@ SAMPLE_GEOM = {
44
44
  ]
45
45
  }
46
46
 
47
+
47
48
  class DatasetAPITest(APITestCase):
48
49
  modules = []
49
50
 
50
51
  def test_dataset_api_list(self):
51
52
  '''It should fetch a dataset list from the API'''
52
- datasets = [VisibleDatasetFactory() for i in range(2)]
53
+ datasets = [DatasetFactory() for i in range(2)]
53
54
 
54
55
  response = self.get(url_for('api.datasets'))
55
56
  self.assert200(response)
@@ -58,10 +59,10 @@ class DatasetAPITest(APITestCase):
58
59
 
59
60
  def test_dataset_api_full_text_search(self):
60
61
  '''Should proceed to full text search on datasets'''
61
- [VisibleDatasetFactory() for i in range(2)]
62
- VisibleDatasetFactory(title="some spécial integer")
63
- VisibleDatasetFactory(title="some spécial float")
64
- dataset = VisibleDatasetFactory(title="some spécial chars")
62
+ [DatasetFactory() for i in range(2)]
63
+ DatasetFactory(title="some spécial integer")
64
+ DatasetFactory(title="some spécial float")
65
+ dataset = DatasetFactory(title="some spécial chars")
65
66
 
66
67
  # with accent
67
68
  response = self.get(url_for('api.datasets', q='some spécial chars'))
@@ -82,9 +83,9 @@ class DatasetAPITest(APITestCase):
82
83
  def test_dataset_api_sorting(self):
83
84
  '''Should sort datasets results from the API'''
84
85
  self.login()
85
- [VisibleDatasetFactory() for i in range(2)]
86
+ [DatasetFactory() for i in range(2)]
86
87
 
87
- to_follow = VisibleDatasetFactory(title="dataset to follow")
88
+ to_follow = DatasetFactory(title="dataset to follow")
88
89
 
89
90
  response = self.post(url_for('api.dataset_followers', id=to_follow.id))
90
91
  self.assert201(response)
@@ -100,8 +101,8 @@ class DatasetAPITest(APITestCase):
100
101
 
101
102
  def test_dataset_api_sorting_created(self):
102
103
  self.login()
103
- first = VisibleDatasetFactory(title="first created dataset")
104
- second = VisibleDatasetFactory(title="second created dataset")
104
+ first = DatasetFactory(title="first created dataset")
105
+ second = DatasetFactory(title="second created dataset")
105
106
  response = self.get(url_for('api.datasets', sort='created'))
106
107
  self.assert200(response)
107
108
  self.assertEqual(response.json['data'][0]['id'], str(first.id))
@@ -123,8 +124,8 @@ class DatasetAPITest(APITestCase):
123
124
  def test_dataset_api_default_sorting(self):
124
125
  # Default sort should be -created
125
126
  self.login()
126
- [VisibleDatasetFactory(title="some created dataset") for i in range(10)]
127
- last = VisibleDatasetFactory(title="last created dataset")
127
+ [DatasetFactory(title="some created dataset") for i in range(10)]
128
+ last = DatasetFactory(title="last created dataset")
128
129
  response = self.get(url_for('api.datasets'))
129
130
  self.assert200(response)
130
131
  self.assertEqual(response.json['data'][0]['id'], str(last.id))
@@ -134,31 +135,31 @@ class DatasetAPITest(APITestCase):
134
135
  owner = UserFactory()
135
136
  org = OrganizationFactory()
136
137
 
137
- [VisibleDatasetFactory() for i in range(2)]
138
+ [DatasetFactory() for i in range(2)]
138
139
 
139
- tag_dataset = VisibleDatasetFactory(tags=['my-tag', 'other'])
140
- license_dataset = VisibleDatasetFactory(license=LicenseFactory(id='cc-by'))
140
+ tag_dataset = DatasetFactory(tags=['my-tag', 'other'])
141
+ license_dataset = DatasetFactory(license=LicenseFactory(id='cc-by'))
141
142
  format_dataset = DatasetFactory(resources=[ResourceFactory(format='my-format')])
142
- featured_dataset = VisibleDatasetFactory(featured=True)
143
- topic_dataset = VisibleDatasetFactory()
143
+ featured_dataset = DatasetFactory(featured=True)
144
+ topic_dataset = DatasetFactory()
144
145
  topic = TopicFactory(datasets=[topic_dataset])
145
146
 
146
147
  paca, _, _ = create_geozones_fixtures()
147
- geozone_dataset = VisibleDatasetFactory(spatial=SpatialCoverageFactory(zones=[paca.id]))
148
- granularity_dataset = VisibleDatasetFactory(
148
+ geozone_dataset = DatasetFactory(spatial=SpatialCoverageFactory(zones=[paca.id]))
149
+ granularity_dataset = DatasetFactory(
149
150
  spatial=SpatialCoverageFactory(granularity='country')
150
151
  )
151
152
 
152
153
  temporal_coverage = db.DateRange(start='2022-05-03', end='2022-05-04')
153
154
  temporal_coverage_dataset = DatasetFactory(temporal_coverage=temporal_coverage)
154
155
 
155
- owner_dataset = VisibleDatasetFactory(owner=owner)
156
- org_dataset = VisibleDatasetFactory(organization=org)
156
+ owner_dataset = DatasetFactory(owner=owner)
157
+ org_dataset = DatasetFactory(organization=org)
157
158
 
158
- schema_dataset = VisibleDatasetFactory(resources=[
159
+ schema_dataset = DatasetFactory(resources=[
159
160
  ResourceFactory(schema={'name': 'my-schema', 'url': 'https://example.org', 'version': '1.0.0'})
160
161
  ])
161
- schema_version2_dataset = VisibleDatasetFactory(resources=[
162
+ schema_version2_dataset = DatasetFactory(resources=[
162
163
  ResourceFactory(schema={'name': 'other-schema', 'url': 'https://example.org', 'version': '2.0.0'})
163
164
  ])
164
165
 
@@ -270,7 +271,7 @@ class DatasetAPITest(APITestCase):
270
271
 
271
272
  def test_dataset_api_get_deleted(self):
272
273
  '''It should not fetch a deleted dataset from the API and raise 410'''
273
- dataset = VisibleDatasetFactory(deleted=datetime.utcnow())
274
+ dataset = DatasetFactory(deleted=datetime.utcnow())
274
275
 
275
276
  response = self.get(url_for('api.dataset', dataset=dataset))
276
277
  self.assert410(response)
@@ -278,7 +279,7 @@ class DatasetAPITest(APITestCase):
278
279
  def test_dataset_api_get_deleted_but_authorized(self):
279
280
  '''It should a deleted dataset from the API if user is authorized'''
280
281
  self.login()
281
- dataset = VisibleDatasetFactory(owner=self.user,
282
+ dataset = DatasetFactory(owner=self.user,
282
283
  deleted=datetime.utcnow())
283
284
 
284
285
  response = self.get(url_for('api.dataset', dataset=dataset))
@@ -451,7 +452,7 @@ class DatasetAPITest(APITestCase):
451
452
  def test_dataset_api_update_with_resources(self):
452
453
  '''It should update a dataset from the API with resources parameters'''
453
454
  user = self.login()
454
- dataset = VisibleDatasetFactory(owner=user)
455
+ dataset = DatasetFactory(owner=user)
455
456
  initial_length = len(dataset.resources)
456
457
  data = dataset.to_dict()
457
458
  data['resources'].append(ResourceFactory.as_dict())
@@ -464,7 +465,7 @@ class DatasetAPITest(APITestCase):
464
465
 
465
466
  def test_dataset_api_update_private(self):
466
467
  user = self.login()
467
- dataset = DatasetFactory(owner=user, private=True)
468
+ dataset = HiddenDatasetFactory(owner=user)
468
469
  data = dataset.to_dict()
469
470
  data['description'] = 'new description'
470
471
  del data['private']
@@ -487,12 +488,10 @@ class DatasetAPITest(APITestCase):
487
488
  dataset.reload()
488
489
  self.assertEqual(dataset.private, True)
489
490
 
490
-
491
-
492
491
  def test_dataset_api_update_new_resource_with_extras(self):
493
492
  '''It should update a dataset with a new resource with extras'''
494
493
  user = self.login()
495
- dataset = VisibleDatasetFactory(owner=user)
494
+ dataset = DatasetFactory(owner=user)
496
495
  data = dataset.to_dict()
497
496
  resource_data = ResourceFactory.as_dict()
498
497
  resource_data['extras'] = {'extra:id': 'id'}
@@ -508,7 +507,7 @@ class DatasetAPITest(APITestCase):
508
507
  def test_dataset_api_update_existing_resource_with_extras(self):
509
508
  '''It should update a dataset's existing resource with extras'''
510
509
  user = self.login()
511
- dataset = VisibleDatasetFactory(owner=user)
510
+ dataset = DatasetFactory(owner=user, nb_resources=1)
512
511
  data = dataset.to_dict()
513
512
  data['resources'][0]['extras'] = {'extra:id': 'id'}
514
513
  response = self.put(url_for('api.dataset', dataset=dataset), data)
@@ -683,7 +682,7 @@ class DatasetAPITest(APITestCase):
683
682
  def test_dataset_api_delete(self):
684
683
  '''It should delete a dataset from the API'''
685
684
  user = self.login()
686
- dataset = VisibleDatasetFactory(owner=user)
685
+ dataset = DatasetFactory(owner=user, nb_resources=1)
687
686
  response = self.delete(url_for('api.dataset', dataset=dataset))
688
687
 
689
688
  self.assertStatus(response, 204)
@@ -697,7 +696,7 @@ class DatasetAPITest(APITestCase):
697
696
  def test_dataset_api_delete_deleted(self):
698
697
  '''It should delete a deleted dataset from the API and raise 410'''
699
698
  user = self.login()
700
- dataset = VisibleDatasetFactory(owner=user, deleted=datetime.utcnow())
699
+ dataset = DatasetFactory(owner=user, deleted=datetime.utcnow(), nb_resources=1)
701
700
  response = self.delete(url_for('api.dataset', dataset=dataset))
702
701
 
703
702
  self.assert410(response)
@@ -1472,8 +1471,8 @@ class DatasetArchivedAPITest(APITestCase):
1472
1471
 
1473
1472
  def test_dataset_api_search_archived(self):
1474
1473
  '''It should search datasets from the API, excluding archived ones'''
1475
- VisibleDatasetFactory(archived=None)
1476
- dataset = VisibleDatasetFactory(archived=datetime.utcnow())
1474
+ DatasetFactory(archived=None)
1475
+ dataset = DatasetFactory(archived=datetime.utcnow())
1477
1476
 
1478
1477
  response = self.get(url_for('api.datasets', q=''))
1479
1478
  self.assert200(response)
@@ -1483,7 +1482,7 @@ class DatasetArchivedAPITest(APITestCase):
1483
1482
 
1484
1483
  def test_dataset_api_get_archived(self):
1485
1484
  '''It should fetch an archived dataset from the API and return 200'''
1486
- dataset = VisibleDatasetFactory(archived=datetime.utcnow())
1485
+ dataset = DatasetFactory(archived=datetime.utcnow())
1487
1486
  response = self.get(url_for('api.dataset', dataset=dataset))
1488
1487
  self.assert200(response)
1489
1488
 
@@ -1528,7 +1527,7 @@ class CommunityResourceAPITest(APITestCase):
1528
1527
 
1529
1528
  def test_community_resource_api_create_dataset_binding(self):
1530
1529
  '''It should create a community resource linked to the right dataset'''
1531
- dataset = VisibleDatasetFactory()
1530
+ dataset = DatasetFactory()
1532
1531
  self.login()
1533
1532
  response = self.post(
1534
1533
  url_for('api.upload_new_community_resource', dataset=dataset),
@@ -1540,7 +1539,7 @@ class CommunityResourceAPITest(APITestCase):
1540
1539
 
1541
1540
  def test_community_resource_api_create(self):
1542
1541
  '''It should create a community resource from the API'''
1543
- dataset = VisibleDatasetFactory()
1542
+ dataset = DatasetFactory()
1544
1543
  self.login()
1545
1544
  response = self.post(
1546
1545
  url_for('api.upload_new_community_resource', dataset=dataset),
@@ -1560,7 +1559,7 @@ class CommunityResourceAPITest(APITestCase):
1560
1559
 
1561
1560
  def test_community_resource_api_create_as_org(self):
1562
1561
  '''It should create a community resource as org from the API'''
1563
- dataset = VisibleDatasetFactory()
1562
+ dataset = DatasetFactory()
1564
1563
  user = self.login()
1565
1564
  org = OrganizationFactory(members=[
1566
1565
  Member(user=user, role='admin')
@@ -1612,7 +1611,7 @@ class CommunityResourceAPITest(APITestCase):
1612
1611
 
1613
1612
  def test_community_resource_api_update_with_file(self):
1614
1613
  '''It should update a community resource file from the API'''
1615
- dataset = VisibleDatasetFactory()
1614
+ dataset = DatasetFactory()
1616
1615
  user = self.login()
1617
1616
  community_resource = CommunityResourceFactory(dataset=dataset,
1618
1617
  owner=user)
@@ -1637,7 +1636,7 @@ class CommunityResourceAPITest(APITestCase):
1637
1636
 
1638
1637
  def test_community_resource_file_update_old_file_deletion(self):
1639
1638
  '''It should update a community resource's file and delete the old one'''
1640
- dataset = VisibleDatasetFactory()
1639
+ dataset = DatasetFactory()
1641
1640
  user = self.login()
1642
1641
  community_resource = CommunityResourceFactory(dataset=dataset,
1643
1642
  owner=user)
@@ -1664,7 +1663,7 @@ class CommunityResourceAPITest(APITestCase):
1664
1663
  def test_community_resource_api_create_remote(self):
1665
1664
  '''It should create a remote community resource from the API'''
1666
1665
  user = self.login()
1667
- dataset = VisibleDatasetFactory()
1666
+ dataset = DatasetFactory()
1668
1667
  attrs = CommunityResourceFactory.as_dict()
1669
1668
  attrs['filetype'] = 'remote'
1670
1669
  attrs['dataset'] = str(dataset.id)
@@ -1685,7 +1684,7 @@ class CommunityResourceAPITest(APITestCase):
1685
1684
  def test_community_resource_api_unallowed_create_filetype_file(self):
1686
1685
  '''It should create a remote community resource from the API'''
1687
1686
  self.login()
1688
- dataset = VisibleDatasetFactory()
1687
+ dataset = DatasetFactory()
1689
1688
  attrs = CommunityResourceFactory.as_dict()
1690
1689
  attrs['filetype'] = 'file' # to be explicit
1691
1690
  attrs['dataset'] = str(dataset.id)
@@ -1734,7 +1733,7 @@ class CommunityResourceAPITest(APITestCase):
1734
1733
  self.assertEqual(CommunityResource.objects.count(), 0)
1735
1734
 
1736
1735
  def test_community_resource_api_delete(self):
1737
- dataset = VisibleDatasetFactory()
1736
+ dataset = DatasetFactory()
1738
1737
  self.login()
1739
1738
 
1740
1739
  response = self.post(
@@ -6,8 +6,7 @@ from udata.models import Discussion, Follow, Member, User
6
6
  from udata.core.discussions.models import Message as DiscMsg
7
7
  from udata.core.dataset.factories import (
8
8
  CommunityResourceFactory,
9
- DatasetFactory,
10
- VisibleDatasetFactory,
9
+ DatasetFactory
11
10
  )
12
11
  from udata.core.dataset.activities import UserCreatedDataset
13
12
  from udata.core.discussions.factories import DiscussionFactory
@@ -89,9 +88,9 @@ class MeAPITest(APITestCase):
89
88
  member = Member(user=user, role='editor')
90
89
  organization = OrganizationFactory(members=[member])
91
90
  community_resources = [
92
- VisibleDatasetFactory(owner=user) for _ in range(2)]
91
+ DatasetFactory(owner=user) for _ in range(2)]
93
92
  org_datasets = [
94
- VisibleDatasetFactory(organization=organization)
93
+ DatasetFactory(organization=organization)
95
94
  for _ in range(2)]
96
95
 
97
96
  response = self.get(url_for('api.my_org_datasets'))
@@ -105,15 +104,15 @@ class MeAPITest(APITestCase):
105
104
  member = Member(user=user, role='editor')
106
105
  organization = OrganizationFactory(members=[member])
107
106
  datasets = [
108
- VisibleDatasetFactory(owner=user, title='foô'),
107
+ DatasetFactory(owner=user, title='foô'),
109
108
  ]
110
109
  org_datasets = [
111
- VisibleDatasetFactory(organization=organization, title='foô'),
110
+ DatasetFactory(organization=organization, title='foô'),
112
111
  ]
113
112
 
114
113
  # Should not be listed.
115
- VisibleDatasetFactory(owner=user)
116
- VisibleDatasetFactory(organization=organization)
114
+ DatasetFactory(owner=user)
115
+ DatasetFactory(organization=organization)
117
116
 
118
117
  response = self.get(url_for('api.my_org_datasets'),
119
118
  qs={'q': 'foô'})
@@ -195,8 +194,8 @@ class MeAPITest(APITestCase):
195
194
  organization = OrganizationFactory(members=[member])
196
195
  reuse = ReuseFactory(owner=user)
197
196
  org_reuse = ReuseFactory(organization=organization)
198
- dataset = VisibleDatasetFactory(owner=user)
199
- org_dataset = VisibleDatasetFactory(organization=organization)
197
+ dataset = DatasetFactory(owner=user)
198
+ org_dataset = DatasetFactory(organization=organization)
200
199
 
201
200
  discussions = [
202
201
  Discussion.objects.create(subject=dataset, title='', user=user),
@@ -206,7 +205,7 @@ class MeAPITest(APITestCase):
206
205
  ]
207
206
 
208
207
  # Should not be listed
209
- Discussion.objects.create(subject=VisibleDatasetFactory(), title='', user=user)
208
+ Discussion.objects.create(subject=DatasetFactory(), title='', user=user)
210
209
  Discussion.objects.create(subject=ReuseFactory(), title='', user=user)
211
210
 
212
211
  response = self.get(url_for('api.my_org_discussions'))
@@ -219,8 +218,8 @@ class MeAPITest(APITestCase):
219
218
  organization = OrganizationFactory(members=[member])
220
219
  reuse = ReuseFactory(owner=user)
221
220
  org_reuse = ReuseFactory(organization=organization)
222
- dataset = VisibleDatasetFactory(owner=user)
223
- org_dataset = VisibleDatasetFactory(organization=organization)
221
+ dataset = DatasetFactory(owner=user)
222
+ org_dataset = DatasetFactory(organization=organization)
224
223
 
225
224
  discussions = [
226
225
  Discussion.objects.create(subject=dataset, title='foô', user=user),
@@ -232,7 +231,7 @@ class MeAPITest(APITestCase):
232
231
  Discussion.objects.create(subject=org_dataset, title='', user=user),
233
232
 
234
233
  # Should really not be listed.
235
- Discussion.objects.create(subject=VisibleDatasetFactory(), title='foô', user=user)
234
+ Discussion.objects.create(subject=DatasetFactory(), title='foô', user=user)
236
235
  Discussion.objects.create(subject=ReuseFactory(), title='foô', user=user)
237
236
 
238
237
  response = self.get(url_for('api.my_org_discussions'), qs={'q': 'foô'})
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
3
  from udata.core.dataset.actions import archive
4
- from udata.core.dataset.factories import VisibleDatasetFactory
4
+ from udata.core.dataset.factories import DatasetFactory
5
5
  from udata.core.discussions.models import Discussion
6
6
  from udata.core.user.factories import UserFactory
7
7
 
@@ -13,7 +13,7 @@ class DatasetActionsTest:
13
13
  user = UserFactory()
14
14
  app.config['ARCHIVE_COMMENT_USER_ID'] = user.id
15
15
 
16
- dataset = VisibleDatasetFactory()
16
+ dataset = DatasetFactory()
17
17
 
18
18
  archive(dataset, comment=True)
19
19
 
@@ -2,14 +2,14 @@ import pytest
2
2
 
3
3
  from tempfile import NamedTemporaryFile
4
4
 
5
- from udata.core.dataset.factories import VisibleDatasetFactory
5
+ from udata.core.dataset.factories import DatasetFactory
6
6
 
7
7
 
8
8
  @pytest.mark.usefixtures('clean_db')
9
9
  class DatasetCommandTest:
10
10
 
11
11
  def test_dataset_archive_one(self, cli):
12
- dataset = VisibleDatasetFactory()
12
+ dataset = DatasetFactory()
13
13
 
14
14
  cli('dataset', 'archive-one', str(dataset.id))
15
15
 
@@ -17,7 +17,7 @@ class DatasetCommandTest:
17
17
  assert dataset.archived is not None
18
18
 
19
19
  def test_dataset_archive(self, cli):
20
- datasets = [VisibleDatasetFactory() for _ in range(2)]
20
+ datasets = [DatasetFactory() for _ in range(2)]
21
21
 
22
22
  with NamedTemporaryFile(mode='w', encoding='utf8') as temp:
23
23
  temp.write('\n'.join((str(d.id) for d in datasets)))
@@ -1,6 +1,6 @@
1
1
  from datetime import datetime
2
2
 
3
- from udata.core.dataset.factories import DatasetFactory, VisibleDatasetFactory
3
+ from udata.core.dataset.factories import DatasetFactory, HiddenDatasetFactory
4
4
  from udata.core.organization.factories import OrganizationFactory
5
5
  from udata.core.followers.signals import on_follow, on_unfollow
6
6
  from udata.core.reuse.factories import ReuseFactory, VisibleReuseFactory
@@ -27,8 +27,8 @@ class OrganizationModelTest(TestCase, DBTestMixin):
27
27
  reuse = VisibleReuseFactory(organization=org)
28
28
  ReuseFactory(organization=org)
29
29
  with assert_emit(Dataset.on_create):
30
- dataset = VisibleDatasetFactory(organization=org)
31
- DatasetFactory(organization=org)
30
+ dataset = DatasetFactory(organization=org)
31
+ HiddenDatasetFactory(organization=org)
32
32
  with assert_emit(on_follow):
33
33
  follow = Follow.objects.create(following=org, follower=UserFactory(),
34
34
  since=datetime.utcnow())
@@ -9,7 +9,7 @@ from udata.rdf import DCAT, DCT, HYDRA
9
9
  from udata.tests import TestCase, DBTestMixin
10
10
  from udata.core.organization.factories import OrganizationFactory
11
11
  from udata.core.organization.rdf import organization_to_rdf, build_org_catalog
12
- from udata.core.dataset.factories import VisibleDatasetFactory
12
+ from udata.core.dataset.factories import DatasetFactory
13
13
  from udata.core.dataset.models import Dataset
14
14
  from udata.utils import faker
15
15
 
@@ -57,7 +57,7 @@ class OrganizationToRdfTest(DBTestMixin, TestCase):
57
57
  origin_org = OrganizationFactory()
58
58
  uri = url_for('api.organization_rdf', org=origin_org.id, _external=True)
59
59
 
60
- datasets = VisibleDatasetFactory.create_batch(3, organization=origin_org)
60
+ datasets = DatasetFactory.create_batch(3, organization=origin_org)
61
61
  catalog = build_org_catalog(origin_org, datasets)
62
62
 
63
63
  graph = catalog.graph
@@ -93,7 +93,7 @@ class OrganizationToRdfTest(DBTestMixin, TestCase):
93
93
  page=1, page_size=page_size, _external=True)
94
94
  uri_last = url_for('api.organization_rdf_format', org=origin_org.id, format='json',
95
95
  page=2, page_size=page_size, _external=True)
96
- VisibleDatasetFactory.create_batch(total, organization=origin_org)
96
+ DatasetFactory.create_batch(total, organization=origin_org)
97
97
 
98
98
  # First page
99
99
  datasets = Dataset.objects.paginate(1, page_size)
@@ -5,7 +5,7 @@ from udata.models import Reuse
5
5
  from udata.core.dataset import tasks as dataset_tasks
6
6
  from udata.core.organization.factories import OrganizationFactory
7
7
  from udata.core.reuse.factories import ReuseFactory, VisibleReuseFactory
8
- from udata.core.dataset.factories import VisibleDatasetFactory
8
+ from udata.core.dataset.factories import DatasetFactory
9
9
  from udata.core.user.factories import UserFactory
10
10
  from udata.core.discussions.factories import DiscussionFactory
11
11
  from udata.i18n import gettext as _
@@ -65,7 +65,7 @@ class ReuseModelTest(TestCase, DBTestMixin):
65
65
  reuse.save()
66
66
 
67
67
  def test_reuse_metrics(self):
68
- dataset = VisibleDatasetFactory()
68
+ dataset = DatasetFactory()
69
69
  reuse = VisibleReuseFactory()
70
70
  DiscussionFactory(subject=reuse)
71
71