Skip to content

Commit

Permalink
Add update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudDauce committed Feb 8, 2024
1 parent 9c21310 commit 25e130e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions udata/tests/api/test_datasets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,32 @@ def test_dataset_new_resource_with_schema(self, rmock):
assert dataset.resources[0].schema['url'] == None
assert dataset.resources[0].schema['version'] == '2.2.1'

# Putting `None` as the schema argument do not remove the schema
# Not sure if it's the correct behaviour but it's the normal behaviour on the API v1… :-(
data = response.json
data['resources'][0]['schema'] = None
response = self.put(url_for('api.dataset', dataset=dataset), data)
self.assert200(response)

dataset.reload()
assert dataset.resources[0].schema['name'] == 'etalab/schema-irve-statique'
assert dataset.resources[0].schema['url'] == None
assert dataset.resources[0].schema['version'] == '2.2.1'

# Putting `None` as the schema name and version remove the schema
# This is a workaround for the None on schema behaviour explain above.
data = response.json
data['resources'][0]['schema']['name'] = None
data['resources'][0]['schema']['version'] = None

response = self.put(url_for('api.dataset', dataset=dataset), data)
self.assert200(response)

dataset.reload()
assert dataset.resources[0].schema['name'] == None
assert dataset.resources[0].schema['url'] == None
assert dataset.resources[0].schema['version'] == None


class DatasetBadgeAPITest(APITestCase):
@classmethod
Expand Down

0 comments on commit 25e130e

Please sign in to comment.