Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_read_metadata.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from django.core.urlresolvers import reverse | from django.core.urlresolvers import reverse | ||||
from rest_framework import status | from rest_framework import status | ||||
from rest_framework.test import APITestCase | from rest_framework.test import APITestCase | ||||
Show All 35 Lines | def test_read_metadata(self): | ||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id', | 'some-external-id', | ||||
'type': 'deposit' | 'type': 'deposit' | ||||
}, | }, | ||||
'origin_metadata': { | 'origin_metadata': { | ||||
'metadata': { | 'metadata': { | ||||
'@xmlns': ['http://www.w3.org/2005/Atom'], | '@xmlns': ['http://www.w3.org/2005/Atom'], | ||||
'author': ['some awesome author', 'another one', 'no one'], | 'author': ['some awesome author', 'another one', 'no one'], | ||||
'codemeta:dateCreated': '2017-10-07T15:17:08Z', | |||||
'external_identifier': 'some-external-id', | 'external_identifier': 'some-external-id', | ||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id' | 'some-external-id' | ||||
}, | }, | ||||
'provider': { | 'provider': { | ||||
'provider_name': 'hal', | 'provider_name': 'hal', | ||||
'provider_type': 'deposit_client', | 'provider_type': 'deposit_client', | ||||
'provider_url': 'https://hal-test.archives-ouvertes.fr/', | 'provider_url': 'https://hal-test.archives-ouvertes.fr/', | ||||
'metadata': {} | 'metadata': {} | ||||
}, | }, | ||||
'tool': { | 'tool': { | ||||
'name': 'swh-deposit', | 'name': 'swh-deposit', | ||||
'version': '0.0.1', | 'version': '0.0.1', | ||||
'configuration': { | 'configuration': { | ||||
'sword_version': '2' | 'sword_version': '2' | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
'revision': { | 'revision': { | ||||
'synthetic': True, | 'synthetic': True, | ||||
'committer_date': None, | 'committer_date': { | ||||
'timestamp': { | |||||
'seconds': 1507389428, | |||||
'microseconds': 0 | |||||
}, | |||||
'offset': 0, | |||||
'negative_utc': False | |||||
}, | |||||
'message': 'hal: Deposit %s in collection hal' % deposit_id, | 'message': 'hal: Deposit %s in collection hal' % deposit_id, | ||||
'author': SWH_PERSON, | 'author': SWH_PERSON, | ||||
'committer': SWH_PERSON, | 'committer': SWH_PERSON, | ||||
'date': None, | 'date': None, | ||||
'metadata': { | 'metadata': { | ||||
'@xmlns': ['http://www.w3.org/2005/Atom'], | '@xmlns': ['http://www.w3.org/2005/Atom'], | ||||
'author': ['some awesome author', 'another one', 'no one'], | 'author': ['some awesome author', 'another one', 'no one'], | ||||
'external_identifier': 'some-external-id', | 'external_identifier': 'some-external-id', | ||||
'codemeta:dateCreated': '2017-10-07T15:17:08Z', | |||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id' | 'some-external-id' | ||||
}, | }, | ||||
'type': 'tar' | 'type': 'tar' | ||||
}, | }, | ||||
'branch_name': 'master', | 'branch_name': 'master', | ||||
} | } | ||||
Show All 40 Lines | def test_read_metadata_revision_with_parent(self): | ||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id', | 'some-external-id', | ||||
'type': 'deposit' | 'type': 'deposit' | ||||
}, | }, | ||||
'origin_metadata': { | 'origin_metadata': { | ||||
'metadata': { | 'metadata': { | ||||
'@xmlns': ['http://www.w3.org/2005/Atom'], | '@xmlns': ['http://www.w3.org/2005/Atom'], | ||||
'author': ['some awesome author', 'another one', 'no one'], | 'author': ['some awesome author', 'another one', 'no one'], | ||||
'codemeta:dateCreated': '2017-10-07T15:17:08Z', | |||||
'external_identifier': 'some-external-id', | 'external_identifier': 'some-external-id', | ||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id' | 'some-external-id' | ||||
}, | }, | ||||
'provider': { | 'provider': { | ||||
'provider_name': 'hal', | 'provider_name': 'hal', | ||||
'provider_type': 'deposit_client', | 'provider_type': 'deposit_client', | ||||
'provider_url': 'https://hal-test.archives-ouvertes.fr/', | 'provider_url': 'https://hal-test.archives-ouvertes.fr/', | ||||
'metadata': {} | 'metadata': {} | ||||
}, | }, | ||||
'tool': { | 'tool': { | ||||
'name': 'swh-deposit', | 'name': 'swh-deposit', | ||||
'version': '0.0.1', | 'version': '0.0.1', | ||||
'configuration': { | 'configuration': { | ||||
'sword_version': '2' | 'sword_version': '2' | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
'revision': { | 'revision': { | ||||
'synthetic': True, | 'synthetic': True, | ||||
'date': None, | 'date': None, | ||||
'committer_date': None, | 'committer_date': { | ||||
'timestamp': { | |||||
'seconds': 1507389428, | |||||
'microseconds': 0 | |||||
}, | |||||
'offset': 0, | |||||
'negative_utc': False | |||||
}, | |||||
'author': SWH_PERSON, | 'author': SWH_PERSON, | ||||
'committer': SWH_PERSON, | 'committer': SWH_PERSON, | ||||
'type': 'tar', | 'type': 'tar', | ||||
'message': 'hal: Deposit %s in collection hal' % deposit_id, | 'message': 'hal: Deposit %s in collection hal' % deposit_id, | ||||
'metadata': { | 'metadata': { | ||||
'@xmlns': ['http://www.w3.org/2005/Atom'], | '@xmlns': ['http://www.w3.org/2005/Atom'], | ||||
'author': ['some awesome author', 'another one', 'no one'], | 'author': ['some awesome author', 'another one', 'no one'], | ||||
'codemeta:dateCreated': '2017-10-07T15:17:08Z', | |||||
'external_identifier': 'some-external-id', | 'external_identifier': 'some-external-id', | ||||
'url': 'https://hal-test.archives-ouvertes.fr/' + | 'url': 'https://hal-test.archives-ouvertes.fr/' + | ||||
'some-external-id' | 'some-external-id' | ||||
}, | }, | ||||
'parents': [swh_id] | 'parents': [swh_id] | ||||
}, | }, | ||||
'branch_name': 'master', | 'branch_name': 'master', | ||||
} | } | ||||
Show All 22 Lines | def test_access_to_nonexisting_collection_returns_404_response(self): | ||||
deposit_id = self.create_deposit_partial() | deposit_id = self.create_deposit_partial() | ||||
url = reverse(PRIVATE_GET_DEPOSIT_METADATA, | url = reverse(PRIVATE_GET_DEPOSIT_METADATA, | ||||
args=[collection_name, deposit_id]) | args=[collection_name, deposit_id]) | ||||
response = self.client.get(url) | response = self.client.get(url) | ||||
self.assertEqual(response.status_code, | self.assertEqual(response.status_code, | ||||
status.HTTP_404_NOT_FOUND) | status.HTTP_404_NOT_FOUND) | ||||
self.assertIn('Unknown collection name %s' % collection_name, | self.assertIn('Unknown collection name %s' % collection_name, | ||||
response.content.decode('utf-8'),) | response.content.decode('utf-8'),) | ||||
douardda: Couldn't we share this big chunk of xml among tests? I'm a big advocate of copy/paste in tests… | |||||
Done Inline ActionsI'll see what i can do, it sure irritates me a lot... ardumont: I'll see what i can do, it sure irritates me a lot...
I was focused on making the thing works… | |||||
Not Done Inline ActionsThe design choice of taking the first date in the list is good for me moranegg: The design choice of taking the first date in the list is good for me |
Couldn't we share this big chunk of xml among tests? I'm a big advocate of copy/paste in tests (rather than clever abstractions/genericity that make the test hard to read for a human), but in this case, it's hard to guess what the differences are between these tests. The docstrings/comments do describe them, but ...