diff --git a/PKG-INFO b/PKG-INFO
index 98d649b9..c5772c10 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,10 +1,10 @@
Metadata-Version: 1.0
Name: swh.deposit
-Version: 0.0.59
+Version: 0.0.60
Summary: Software Heritage Deposit Server
Home-page: https://forge.softwareheritage.org/source/swh-deposit/
Author: Software Heritage developers
Author-email: swh-devel@inria.fr
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
diff --git a/docs/specs/metadata_example.xml b/docs/specs/metadata_example.xml
index c681e559..7ae6c8e4 100644
--- a/docs/specs/metadata_example.xml
+++ b/docs/specs/metadata_example.xml
@@ -1,35 +1,31 @@
- "{http://www.w3.org/2005/Atom}author": {
- "{http://www.w3.org/2005/Atom}email": "hal@ccsd.cnrs.fr",
- "{http://www.w3.org/2005/Atom}name": "HAL"
- },
HAL
hal@ccsd.cnrs.fr
hal
hal-01243573
The assignment problem
https://hal.archives-ouvertes.fr/hal-01243573
other identifier, DOI, ARK
Domain
description
author1
Inria
UPMC
author2
Inria
UPMC
diff --git a/docs/specs/spec-meta-deposit.rst b/docs/specs/spec-meta-deposit.rst
index 517757fc..887baef2 100644
--- a/docs/specs/spec-meta-deposit.rst
+++ b/docs/specs/spec-meta-deposit.rst
@@ -1,84 +1,98 @@
The metadata-deposit
====================
Goal
----
A client wishes to deposit only metadata about an object in the Software
Heritage archive.
-The meta-deposit is a special deposit where no content is
+The metadata-deposit is a special deposit where no content is
provided and the data transfered to Software Heritage is only
the metadata about an object or several objects in the archive.
Requirements
------------
The scope of the meta-deposit is different than the
sparse-deposit. While a sparse-deposit creates a revision with referenced
-directories and content files, the meta-deposit references one of the following:
+directories and content files, the metadata-deposit references one of the
+following:
- origin
- snapshot
- revision
- release
A complete metadata example
---------------------------
The reference element is included in the metadata xml atomEntry under the
-swh namespace:
+swh namespace (a link for the published schema will be provided during
+the implementation of the metadata deposit):
.. code:: xml
HAL
hal@ccsd.cnrs.fr
hal
hal-01243573
The assignment problem
https://hal.archives-ouvertes.fr/hal-01243573
other identifier, DOI, ARK
Domain
description
author1
Inria
UPMC
author2
Inria
UPMC
Examples by target type
^^^^^^^^^^^^^^^^^^^^^^^
+Reference an origin:
-With ${type} in {snp (snapshot), rev (revision), rel (release) }:
+.. code:: xml
+
+
+
+
+
+
+
+
+Reference a snapshot, revision or release:
.. code:: xml
+ With ${type} in {snp (snapshot), rev (revision), rel (release) }:
Loading procedure
------------------
-In this case, the meta-deposit will be injected as a metadata entry at the
-appropriate level (origin_metadata, revision_metadata, etc.). Contrary to the
-complete and sparse deposit, there will be no object creation.
+In this case, the metadata-deposit will be injected as a metadata entry at the
+appropriate level (origin_metadata, revision_metadata, etc.) with the information
+about the contributor of the deposit. Contrary to the complete and sparse
+deposit, there will be no object creation.
diff --git a/docs/specs/spec-sparse-deposit.rst b/docs/specs/spec-sparse-deposit.rst
index e08f5728..ffa001ae 100644
--- a/docs/specs/spec-sparse-deposit.rst
+++ b/docs/specs/spec-sparse-deposit.rst
@@ -1,101 +1,102 @@
The sparse-deposit
==================
Goal
----
A client wishes to transfer a tarball for which part of the content is
already in the SWH archive.
Requirements
------------
To do so, a list of paths with targets must be provided in the metadata and
the paths to the missing directories/content should not be included
in the tarball. The list will be referred to
as the manifest list using the entry name 'bindings' in the metadata.
+----------------------+-------------------------------------+
| path | swh-id |
+======================+=====================================+
| path/to/file.txt | swh:1:cnt:aaaaaaaaaaaaaaaaaaaaa... |
+----------------------+-------------------------------------+
| path/to/dir/ | swh:1:dir:aaaaaaaaaaaaaaaaaaaaa... |
+----------------------+-------------------------------------+
Note: the *name* of the file or the directory is given by the path and is not
part of the identified object.
A concrete example
------------------
The manifest list is included in the metadata xml atomEntry under the
-swh namespace:
+swh namespace (a link for the published schema will be provided during
+the implementation of the sparse deposit):
.. code:: xml
HAL
hal@ccsd.cnrs.fr
hal
hal-01243573
The assignment problem
https://hal.archives-ouvertes.fr/hal-01243573
other identifier, DOI, ARK
Domain
description
author1
Inria
UPMC
author2
Inria
UPMC
Deposit verification
--------------------
After checking the integrity of the deposit content and
metadata, the following checks should be added:
1. validate the manifest list structure with a correct swh-id for each path (syntax check on the swh-id format)
2. verify that the path name corresponds to the object type
3. locate the identifiers in the SWH archive
Each failing check should return a different error with the deposit
and result in a 'rejected' deposit.
Loading procedure
------------------
The injection procedure should include:
- load the tarball new data
- create new objects using the path name and create links from the path to the
SWH object using the identifier
- calculate identifier of the new objects at each level
- return final swh-id of the new revision
Invariant: the same content should yield the same swh-id,
that's why a complete deposit with all the content and
a sparse-deposit with the correct links will result
with the same root directory swh-id.
The same is expected with the revision swh-id if the metadata provided is
identical.
diff --git a/requirements-test.txt b/requirements-test.txt
new file mode 100644
index 00000000..f3c7e8e6
--- /dev/null
+++ b/requirements-test.txt
@@ -0,0 +1 @@
+nose
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index cfbbc0ca..3824b5d4
--- a/setup.py
+++ b/setup.py
@@ -1,29 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+
from setuptools import setup, find_packages
-def parse_requirements():
+def parse_requirements(name=None):
+ if name:
+ reqf = 'requirements-%s.txt' % name
+ else:
+ reqf = 'requirements.txt'
+
requirements = []
- for reqf in ('requirements.txt', 'requirements-swh.txt'):
- with open(reqf) as f:
- for line in f.readlines():
- line = line.strip()
- if not line or line.startswith('#'):
- continue
- requirements.append(line)
+ if not os.path.exists(reqf):
+ return requirements
+
+ with open(reqf) as f:
+ for line in f.readlines():
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+ requirements.append(line)
return requirements
setup(
name='swh.deposit',
description='Software Heritage Deposit Server',
author='Software Heritage developers',
author_email='swh-devel@inria.fr',
url='https://forge.softwareheritage.org/source/swh-deposit/',
packages=find_packages(),
scripts=['bin/swh-deposit'], # scripts to package
- install_requires=parse_requirements(),
+ install_requires=parse_requirements() + parse_requirements('swh'),
+ test_requires=parse_requirements('test'),
extras_require={},
setup_requires=['vcversioner'],
vcversioner={},
include_package_data=True,
)
diff --git a/swh.deposit.egg-info/PKG-INFO b/swh.deposit.egg-info/PKG-INFO
index 98d649b9..c5772c10 100644
--- a/swh.deposit.egg-info/PKG-INFO
+++ b/swh.deposit.egg-info/PKG-INFO
@@ -1,10 +1,10 @@
Metadata-Version: 1.0
Name: swh.deposit
-Version: 0.0.59
+Version: 0.0.60
Summary: Software Heritage Deposit Server
Home-page: https://forge.softwareheritage.org/source/swh-deposit/
Author: Software Heritage developers
Author-email: swh-devel@inria.fr
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
diff --git a/swh.deposit.egg-info/SOURCES.txt b/swh.deposit.egg-info/SOURCES.txt
index 0c14a326..e6fcdc9d 100644
--- a/swh.deposit.egg-info/SOURCES.txt
+++ b/swh.deposit.egg-info/SOURCES.txt
@@ -1,163 +1,164 @@
.gitignore
AUTHORS
LICENSE
MANIFEST.in
Makefile
Makefile.local
README.md
requirements-swh.txt
+requirements-test.txt
requirements.txt
setup.py
version.txt
bin/Makefile
bin/content.sh
bin/create_deposit.sh
bin/create_deposit_atom.sh
bin/create_deposit_with_metadata.sh
bin/default-setup
bin/download-deposit-archive.sh
bin/home.sh
bin/replace-deposit-archive.sh
bin/service-document.sh
bin/status.sh
bin/swh-deposit
bin/update-deposit-with-another-archive.sh
bin/update-status.sh
debian/changelog
debian/compat
debian/control
debian/copyright
debian/rules
debian/source/format
docs/.gitignore
docs/Makefile
docs/conf.py
docs/dev-info.rst
docs/getting-started.rst
docs/index.rst
docs/metadata.rst
docs/spec-api.rst
docs/sys-info.rst
docs/_static/.placeholder
docs/_templates/.placeholder
docs/endpoints/collection.rst
docs/endpoints/content.rst
docs/endpoints/service-document.rst
docs/endpoints/status.rst
docs/endpoints/update-media.rst
docs/endpoints/update-metadata.rst
docs/images/deposit-create-chart.png
docs/images/deposit-delete-chart.png
docs/images/deposit-update-chart.png
docs/specs/blueprint.rst
docs/specs/metadata_example.xml
docs/specs/spec-loading.rst
docs/specs/spec-meta-deposit.rst
docs/specs/spec-sparse-deposit.rst
docs/specs/specs.rst
docs/specs/swh.xsd
resources/deposit/server.yml
swh/__init__.py
swh/manage.py
swh.deposit.egg-info/PKG-INFO
swh.deposit.egg-info/SOURCES.txt
swh.deposit.egg-info/dependency_links.txt
swh.deposit.egg-info/requires.txt
swh.deposit.egg-info/top_level.txt
swh/deposit/__init__.py
swh/deposit/apps.py
swh/deposit/auth.py
swh/deposit/config.py
swh/deposit/create_user.py
swh/deposit/errors.py
swh/deposit/models.py
swh/deposit/parsers.py
swh/deposit/signals.py
swh/deposit/urls.py
swh/deposit/utils.py
swh/deposit/wsgi.py
swh/deposit/api/__init__.py
swh/deposit/api/common.py
swh/deposit/api/deposit.py
swh/deposit/api/deposit_content.py
swh/deposit/api/deposit_status.py
swh/deposit/api/deposit_update.py
swh/deposit/api/service_document.py
swh/deposit/api/urls.py
swh/deposit/api/private/__init__.py
swh/deposit/api/private/deposit_check.py
swh/deposit/api/private/deposit_read.py
swh/deposit/api/private/deposit_update_status.py
swh/deposit/api/private/urls.py
swh/deposit/client/__init__.py
swh/deposit/client/cli.py
swh/deposit/fixtures/__init__.py
swh/deposit/fixtures/deposit_data.yaml
swh/deposit/loader/__init__.py
swh/deposit/loader/checker.py
swh/deposit/loader/loader.py
swh/deposit/loader/scheduler.py
swh/deposit/loader/tasks.py
swh/deposit/migrations/0001_initial.py
swh/deposit/migrations/0002_depositrequest_archive.py
swh/deposit/migrations/0003_temporaryarchive.py
swh/deposit/migrations/0004_delete_temporaryarchive.py
swh/deposit/migrations/0005_auto_20171019_1436.py
swh/deposit/migrations/0006_depositclient_url.py
swh/deposit/migrations/0007_auto_20171129_1609.py
swh/deposit/migrations/0008_auto_20171130_1513.py
swh/deposit/migrations/0009_deposit_parent.py
swh/deposit/migrations/0010_auto_20180110_0953.py
swh/deposit/migrations/0011_auto_20180115_1510.py
swh/deposit/migrations/0012_deposit_status_detail.py
swh/deposit/migrations/0013_depositrequest_raw_metadata.py
swh/deposit/migrations/0014_auto_20180720_1221.py
swh/deposit/migrations/__init__.py
swh/deposit/settings/__init__.py
swh/deposit/settings/common.py
swh/deposit/settings/development.py
swh/deposit/settings/production.py
swh/deposit/settings/testing.py
swh/deposit/static/robots.txt
swh/deposit/static/css/bootstrap-responsive.min.css
swh/deposit/static/css/style.css
swh/deposit/static/img/arrow-up-small.png
swh/deposit/static/img/swh-logo-deposit.png
swh/deposit/static/img/swh-logo-deposit.svg
swh/deposit/static/img/icons/swh-logo-32x32.png
swh/deposit/static/img/icons/swh-logo-deposit-180x180.png
swh/deposit/static/img/icons/swh-logo-deposit-192x192.png
swh/deposit/static/img/icons/swh-logo-deposit-270x270.png
swh/deposit/templates/__init__.py
swh/deposit/templates/homepage.html
swh/deposit/templates/layout.html
swh/deposit/templates/deposit/__init__.py
swh/deposit/templates/deposit/content.xml
swh/deposit/templates/deposit/deposit_receipt.xml
swh/deposit/templates/deposit/error.xml
swh/deposit/templates/deposit/service_document.xml
swh/deposit/templates/deposit/status.xml
swh/deposit/templates/rest_framework/api.html
swh/deposit/tests/__init__.py
swh/deposit/tests/common.py
swh/deposit/tests/test_utils.py
swh/deposit/tests/api/__init__.py
swh/deposit/tests/api/test_common.py
swh/deposit/tests/api/test_deposit.py
swh/deposit/tests/api/test_deposit_atom.py
swh/deposit/tests/api/test_deposit_binary.py
swh/deposit/tests/api/test_deposit_check.py
swh/deposit/tests/api/test_deposit_delete.py
swh/deposit/tests/api/test_deposit_multipart.py
swh/deposit/tests/api/test_deposit_read_archive.py
swh/deposit/tests/api/test_deposit_read_metadata.py
swh/deposit/tests/api/test_deposit_status.py
swh/deposit/tests/api/test_deposit_update.py
swh/deposit/tests/api/test_deposit_update_status.py
swh/deposit/tests/api/test_parser.py
swh/deposit/tests/api/test_service_document.py
swh/deposit/tests/loader/__init__.py
swh/deposit/tests/loader/common.py
swh/deposit/tests/loader/test_checker.py
swh/deposit/tests/loader/test_client.py
swh/deposit/tests/loader/test_loader.py
\ No newline at end of file
diff --git a/swh/deposit/api/deposit_status.py b/swh/deposit/api/deposit_status.py
index e212f0ed..31e5b337 100644
--- a/swh/deposit/api/deposit_status.py
+++ b/swh/deposit/api/deposit_status.py
@@ -1,120 +1,118 @@
# Copyright (C) 2017-2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from django.shortcuts import render
from rest_framework import status
from .common import SWHBaseDeposit
from ..errors import NOT_FOUND, make_error_response
from ..errors import make_error_response_from_dict
from ..models import DEPOSIT_STATUS_DETAIL, Deposit
def convert_status_detail(status_detail):
"""Given a status_detail dict, transforms it into a human readable
string.
Dict has the following form (all first level keys are optional):
{
'url': {
'summary': ,
'fields':
},
'metadata': [{
'summary': ,
'fields': ,
}],
'archive': [{
'summary': ,
'fields': ,
}]
}
Args:
status_detail (dict):
Returns:
Status detail as inlined string.
"""
if not status_detail:
return None
+ def _str_fields(data):
+ fields = data.get('fields')
+ if not fields:
+ return ''
+ return ' (%s)' % ', '.join(map(str, fields))
+
msg = []
for key in ['metadata', 'archive']:
_detail = status_detail.get(key)
if _detail:
for data in _detail:
- suffix_msg = ''
- fields = data.get('fields')
- if fields:
- suffix_msg = ' (%s)' % ', '.join(fields)
- msg.append('- %s%s\n' % (data['summary'], suffix_msg))
+ msg.append('- %s%s\n' % (data['summary'], _str_fields(data)))
_detail = status_detail.get('url')
if _detail:
- fields = _detail.get('fields')
- suffix_msg = ''
- if fields:
- suffix_msg = ' (%s)' % ', '.join(fields)
- msg.append('- %s%s\n' % (_detail['summary'], suffix_msg))
+ msg.append('- %s%s\n' % (_detail['summary'], _str_fields(_detail)))
if not msg:
return None
return ''.join(msg)
class SWHDepositStatus(SWHBaseDeposit):
"""Deposit status.
What's known as 'State IRI' in the sword specification.
HTTP verbs supported: GET
"""
def get(self, req, collection_name, deposit_id, format=None):
checks = self.checks(req, collection_name, deposit_id)
if 'error' in checks:
return make_error_response_from_dict(req, checks['error'])
try:
deposit = Deposit.objects.get(pk=deposit_id)
if deposit.collection.name != collection_name:
raise Deposit.DoesNotExist
except Deposit.DoesNotExist:
return make_error_response(
req, NOT_FOUND,
'deposit %s does not belong to collection %s' % (
deposit_id, collection_name))
status_detail = convert_status_detail(deposit.status_detail)
if not status_detail:
status_detail = DEPOSIT_STATUS_DETAIL[deposit.status]
context = {
'deposit_id': deposit.id,
'status': deposit.status,
'status_detail': status_detail,
'swh_id': None,
'swh_id_context': None,
'swh_anchor_id': None,
'swh_anchor_id_context': None,
}
if deposit.swh_id:
context['swh_id'] = deposit.swh_id
if deposit.swh_id_context:
context['swh_id_context'] = deposit.swh_id_context
if deposit.swh_anchor_id:
context['swh_anchor_id'] = deposit.swh_anchor_id
if deposit.swh_anchor_id_context:
context['swh_anchor_id_context'] = deposit.swh_anchor_id_context
return render(req, 'deposit/status.xml',
context=context,
content_type='application/xml',
status=status.HTTP_200_OK)
diff --git a/swh/deposit/tests/api/test_deposit_status.py b/swh/deposit/tests/api/test_deposit_status.py
index abbe07ff..fca43909 100644
--- a/swh/deposit/tests/api/test_deposit_status.py
+++ b/swh/deposit/tests/api/test_deposit_status.py
@@ -1,242 +1,277 @@
# Copyright (C) 2017-2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from django.core.urlresolvers import reverse
from io import BytesIO
from nose.tools import istest
from rest_framework import status
from rest_framework.test import APITestCase
from swh.deposit.api.deposit_status import convert_status_detail
from swh.deposit.config import (COL_IRI, STATE_IRI, DEPOSIT_STATUS_DEPOSITED,
DEPOSIT_STATUS_REJECTED)
from swh.deposit.models import Deposit, DEPOSIT_STATUS_DETAIL
from swh.deposit.models import DEPOSIT_STATUS_LOAD_SUCCESS
from swh.deposit.parsers import parse_xml
from ..common import BasicTestCase, WithAuthTestCase, FileSystemCreationRoutine
from ..common import CommonCreationRoutine
class DepositStatusTestCase(APITestCase, WithAuthTestCase, BasicTestCase,
FileSystemCreationRoutine, CommonCreationRoutine):
"""Status on deposit
"""
@istest
def post_deposit_with_status_check(self):
"""Binary upload should be accepted
"""
# given
url = reverse(COL_IRI, args=[self.collection.name])
external_id = 'some-external-id-1'
# when
response = self.client.post(
url,
content_type='application/zip', # as zip
data=self.archive['data'],
# + headers
CONTENT_LENGTH=self.archive['length'],
HTTP_SLUG=external_id,
HTTP_CONTENT_MD5=self.archive['md5sum'],
HTTP_PACKAGING='http://purl.org/net/sword/package/SimpleZip',
HTTP_IN_PROGRESS='false',
HTTP_CONTENT_DISPOSITION='attachment; filename=filename0')
# then
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
deposit = Deposit.objects.get(external_id=external_id)
status_url = reverse(STATE_IRI,
args=[self.collection.name, deposit.id])
# check status
status_response = self.client.get(status_url)
self.assertEqual(status_response.status_code, status.HTTP_200_OK)
r = parse_xml(BytesIO(status_response.content))
self.assertEqual(int(r['deposit_id']), deposit.id)
self.assertEqual(r['deposit_status'], DEPOSIT_STATUS_DEPOSITED)
self.assertEqual(r['deposit_status_detail'],
DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_DEPOSITED])
@istest
def status_with_swh_information(self):
_status = DEPOSIT_STATUS_LOAD_SUCCESS
_context = 'https://hal.archives-ouvertes.fr/hal-01727745'
_swh_id = 'swh:1:dir:42a13fc721c8716ff695d0d62fc851d641f3a12b'
_swh_id_context = '%s;%s' % (_swh_id, _context)
_swh_anchor_id = 'swh:rev:1:548b3c0a2bb43e1fca191e24b5803ff6b3bc7c10'
_swh_anchor_id_context = '%s;%s' % (_swh_anchor_id, _context)
# given
deposit_id = self.create_deposit_with_status(
status=_status,
swh_id=_swh_id,
swh_id_context=_swh_id_context,
swh_anchor_id=_swh_anchor_id,
swh_anchor_id_context=_swh_anchor_id_context
)
url = reverse(STATE_IRI, args=[self.collection.name, deposit_id])
# when
status_response = self.client.get(url)
# then
self.assertEqual(status_response.status_code, status.HTTP_200_OK)
r = parse_xml(BytesIO(status_response.content))
self.assertEqual(int(r['deposit_id']), deposit_id)
self.assertEqual(r['deposit_status'], _status)
self.assertEqual(r['deposit_status_detail'],
DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_LOAD_SUCCESS])
self.assertEqual(r['deposit_swh_id'], _swh_id)
self.assertEqual(r['deposit_swh_id_context'], _swh_id_context)
self.assertEqual(r['deposit_swh_anchor_id'], _swh_anchor_id)
self.assertEqual(r['deposit_swh_anchor_id_context'],
_swh_anchor_id_context)
@istest
def status_on_unknown_deposit(self):
"""Asking for the status of unknown deposit returns 404 response"""
status_url = reverse(STATE_IRI, args=[self.collection.name, 999])
status_response = self.client.get(status_url)
self.assertEqual(status_response.status_code,
status.HTTP_404_NOT_FOUND)
@istest
def status_with_http_accept_header_should_not_break(self):
"""Asking deposit status with Accept header should return 200
"""
deposit_id = self.create_deposit_partial()
status_url = reverse(STATE_IRI, args=[
self.collection.name, deposit_id])
response = self.client.get(
status_url,
HTTP_ACCEPT='text/html,application/xml;q=9,*/*,q=8')
self.assertEqual(response.status_code, status.HTTP_200_OK)
@istest
def convert_status_detail_empty(self):
actual_status_detail = convert_status_detail({})
self.assertIsNone(actual_status_detail)
actual_status_detail = convert_status_detail({'dummy-keys': []})
self.assertIsNone(actual_status_detail)
actual_status_detail = convert_status_detail(None)
self.assertIsNone(actual_status_detail)
@istest
def convert_status_detail(self):
status_detail = {
'url': {
'summary': "At least one url field must be compatible with the client\'s domain name. The following url fields failed the check", # noqa
'fields': ['blahurl', 'testurl'],
},
'metadata': [
{
'summary': 'Mandatory fields missing',
'fields': ['url', 'title'],
},
{
'summary': 'Alternate fields missing',
'fields': ['name or title', 'url or badurl']
}
],
'archive': [{
'summary': 'Unreadable archive',
'fields': ['1'],
}],
}
expected_status_detail = '''- Mandatory fields missing (url, title)
- Alternate fields missing (name or title, url or badurl)
- Unreadable archive (1)
- At least one url field must be compatible with the client's domain name. The following url fields failed the check (blahurl, testurl)
''' # noqa
actual_status_detail = convert_status_detail(status_detail)
self.assertEqual(actual_status_detail, expected_status_detail)
@istest
def convert_status_detail_2(self):
status_detail = {
'url': {
'summary': 'At least one compatible url field. Failed',
'fields': ['testurl'],
},
'metadata': [
{
'summary': 'Mandatory fields missing',
'fields': ['name'],
},
],
'archive': [
{
'summary': 'Invalid archive',
'fields': ['2'],
},
{
'summary': 'Unsupported archive',
'fields': ['1'],
}
],
}
expected_status_detail = '''- Mandatory fields missing (name)
- Invalid archive (2)
- Unsupported archive (1)
- At least one compatible url field. Failed (testurl)
'''
actual_status_detail = convert_status_detail(status_detail)
self.assertEqual(actual_status_detail, expected_status_detail)
@istest
def convert_status_detail_3(self):
status_detail = {
'url': {
'summary': 'At least one compatible url field',
},
}
expected_status_detail = '- At least one compatible url field\n'
actual_status_detail = convert_status_detail(status_detail)
self.assertEqual(actual_status_detail, expected_status_detail)
+ @istest
+ def convert_status_detail_edge_case(self):
+ status_detail = {
+ 'url': {
+ 'summary': 'At least one compatible url field. Failed',
+ 'fields': ['testurl'],
+ },
+ 'metadata': [
+ {
+ 'summary': 'Mandatory fields missing',
+ 'fields': ['9', 10, 1.212],
+ },
+ ],
+ 'archive': [
+ {
+ 'summary': 'Invalid archive',
+ 'fields': ['3'],
+ },
+ {
+ 'summary': 'Unsupported archive',
+ 'fields': [2],
+ }
+ ],
+ }
+
+ expected_status_detail = '''- Mandatory fields missing (9, 10, 1.212)
+- Invalid archive (3)
+- Unsupported archive (2)
+- At least one compatible url field. Failed (testurl)
+'''
+
+ actual_status_detail = convert_status_detail(status_detail)
+
+ self.assertEqual(actual_status_detail, expected_status_detail)
+
@istest
def status_on_deposit_rejected(self):
_status = DEPOSIT_STATUS_REJECTED
_swh_id = '548b3c0a2bb43e1fca191e24b5803ff6b3bc7c10'
_status_detail = {'url': {'summary': 'Wrong url'}}
# given
deposit_id = self.create_deposit_with_status(
status=_status, swh_id=_swh_id, status_detail=_status_detail)
url = reverse(STATE_IRI, args=[self.collection.name, deposit_id])
# when
status_response = self.client.get(url)
# then
self.assertEqual(status_response.status_code, status.HTTP_200_OK)
r = parse_xml(BytesIO(status_response.content))
self.assertEqual(int(r['deposit_id']), deposit_id)
self.assertEqual(r['deposit_status'], _status)
self.assertEqual(r['deposit_status_detail'], '- Wrong url')
self.assertEqual(r['deposit_swh_id'], _swh_id)
diff --git a/version.txt b/version.txt
index 61d91691..1b9fc6b7 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-v0.0.59-0-g19ca52e
\ No newline at end of file
+v0.0.60-0-gfc4a329
\ No newline at end of file