authenticated_client = <rest_framework.test.APIClient object at 0x7fbd4d36cfd0>
deposit_collection = <DepositCollection: {'id': 113, 'name': 'test'}>
partial_deposit = <Deposit: {'id': 88, 'reception_date': datetime.datetime(2021, 10, 5, 13, 20, 48, 611764, tzinfo=<UTC>), 'collection': 'test', 'external_id': 'external-id-partial', 'origin_url': None, '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_5(
authenticated_client, deposit_collection, partial_deposit, atom_dataset
):
"""dateCreated/datePublished provided, revision uses author/committer
date
If multiple dateCreated provided, the first occurrence (of
dateCreated) is selected. If multiple datePublished provided,
the first occurrence (of datePublished) is selected.
"""
deposit = partial_deposit
# add metadata to the deposit with multiple datePublished/dateCreated
codemeta_entry_data = (
atom_dataset["metadata"]
% """
<codemeta:dateCreated>2015-04-06T17:08:47+02:00</codemeta:dateCreated>
<codemeta:datePublished>2017-05-03T16:08:47+02:00</codemeta:datePublished>
<codemeta:dateCreated>2016-04-06T17:08:47+02:00</codemeta:dateCreated>
<codemeta:datePublished>2018-05-03T16:08:47+02:00</codemeta:datePublished>
"""
)
deposit = update_deposit_with_metadata(
authenticated_client, deposit_collection, deposit, codemeta_entry_data
)
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:337:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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(2015, 4, 6, 17, 8, 47, tzinfo=datetime.timezone(datetime.timedelta(seconds=7200)))
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