authenticated_client = <rest_framework.test.APIClient object at 0x7fbd4d38cc88>
deposit_collection = <DepositCollection: {'id': 110, 'name': 'test'}>
partial_deposit = <Deposit: {'id': 84, 'reception_date': datetime.datetime(2021, 10, 5, 13, 20, 47, 237212, tzinfo=<UTC>), 'collection':...al-id', 'origin_url': 'https://hal-test.archives-ouvertes.fr/some-external-id', 'client': 'test', 'status': 'partial'}>
atom_dataset = {'codemeta-sample': '<?xml version="1.0"?>\n <entry xmlns="http://www.w3.org/2005/Atom"\n xmlns:d...ntry>\n', 'entry-data-empty-body': '<?xml version="1.0"?>\n<entry xmlns="http://www.w3.org/2005/Atom"></entry>\n', ...}
def test_read_metadata_revision_with_parent(
authenticated_client, deposit_collection, partial_deposit, atom_dataset
):
"""Private read metadata to a deposit (with parent) returns metadata
"""
deposit = partial_deposit
deposit.external_id = "some-external-id"
deposit.origin_url = f"https://hal-test.archives-ouvertes.fr/{deposit.external_id}"
deposit.save()
metadata_xml_atoms = [
atom_dataset[atom_key] for atom_key in ["entry-data2", "entry-data3"]
]
metadata_xml_raws = [parse_xml(xml) for xml in metadata_xml_atoms]
for atom_xml in metadata_xml_atoms:
deposit = update_deposit_with_metadata(
authenticated_client, deposit_collection, deposit, atom_xml,
)
rev_id = "da78a9d4cf1d5d29873693fd496142e3a18c20fa"
swhid = "swh:1:rev:%s" % rev_id
fake_parent = Deposit(
swhid=swhid, client=deposit.client, collection=deposit.collection
)
fake_parent.save()
deposit.parent = fake_parent
deposit.save()
for url in private_get_raw_url_endpoints(deposit_collection, deposit):
> response = authenticated_client.get(url)
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_deposit_private_read_metadata.py:132:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:288: in get
response = super().get(path, data=data, **extra)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:205: in get
return self.generic('GET', path, **r)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:234: in generic
method, path, data, content_type, secure, **extra)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:422: in generic
return self.request(**r)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:285: in request
return super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:237: in request
request = super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:503: in request
raise exc_value
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34: in inner
response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:115: in _get_response
response = self.process_exception_by_middleware(e, request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:113: in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
.tox/py3/lib/python3.7/site-packages/django/views/decorators/csrf.py:54: in wrapped_view
return view_func(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/django/views/generic/base.py:71: in view
return self.dispatch(request, *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:509: in dispatch
response = self.handle_exception(exc)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:469: in handle_exception
self.raise_uncaught_exception(exc)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:480: in raise_uncaught_exception
raise exc
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:506: in dispatch
response = handler(request, *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/deposit/api/private/__init__.py:86: in get
return super().get(request, collection_name, deposit_id)
.tox/py3/lib/python3.7/site-packages/swh/deposit/api/common.py:1093: in get
json.dumps(content), status=status, content_type=content_type
/usr/lib/python3.7/json/__init__.py:231: in dumps
return _default_encoder.encode(obj)
/usr/lib/python3.7/json/encoder.py:199: in encode
chunks = self.iterencode(o, _one_shot=True)
/usr/lib/python3.7/json/encoder.py:257: in iterencode
return _iterencode(o, 0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.encoder.JSONEncoder object at 0x7fbd54f49a20>
o = datetime.datetime(2017, 10, 7, 15, 17, 8, tzinfo=datetime.timezone.utc)
def default(self, o):
"""Implement this method in a subclass such that it returns
a serializable object for ``o``, or calls the base implementation
(to raise a ``TypeError``).
For example, to support arbitrary iterators, you could
implement default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
"""
> raise TypeError(f'Object of type {o.__class__.__name__} '
f'is not JSON serializable')
E TypeError: Object of type datetime is not JSON serializable
/usr/lib/python3.7/json/encoder.py:179: TypeError
TEST RESULT
TEST RESULT
- Run At
- Oct 5 2021, 3:21 PM