swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7eff7123ed68>
requests_mock = <requests_mock.mocker.Mocker object at 0x7eff7047da90>
datadir = '/var/lib/jenkins/workspace/DLS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/lister/gitlab/tests/data'
def test_lister_gitlab_with_pages(swh_scheduler, requests_mock, datadir):
"""Gitlab lister supports pagination
"""
instance = "gite.lirmm.fr"
lister = GitLabLister(swh_scheduler, url=api_url(instance))
response1 = gitlab_page_response(datadir, instance, 1)
response2 = gitlab_page_response(datadir, instance, 2)
requests_mock.get(
lister.page_url(1),
[{"json": response1, "headers": {"Link": f"<{lister.page_url(2)}>; rel=next"}}],
additional_matcher=_match_request,
)
requests_mock.get(
lister.page_url(2), [{"json": response2}], additional_matcher=_match_request,
)
> listed_result = lister.run()
.tox/py3/lib/python3.7/site-packages/swh/lister/gitlab/tests/test_lister.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:123: in run
full_stats.origins += self.send_origins(origins)
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:224: in send_origins
ret = self.scheduler.record_listed_origins(origins)
.tox/py3/lib/python3.7/site-packages/swh/core/db/common.py:62: in _meth
return meth(self, *args, db=db, cur=cur, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/scheduler/backend.py:253: in record_listed_origins
fetch=True,
.tox/py3/lib/python3.7/site-packages/psycopg2/extras.py:1284: in execute_values
for page in _paginate(argslist, page_size=page_size):
.tox/py3/lib/python3.7/site-packages/psycopg2/extras.py:1178: in _paginate
page.append(next(it))
.tox/py3/lib/python3.7/site-packages/swh/scheduler/backend.py:250: in <genexpr>
argslist=(attr.asdict(origin) for origin in listed_origins),
.tox/py3/lib/python3.7/site-packages/swh/lister/gitlab/lister.py:180: in get_origins_from_page
last_update=repo["last_activity_at"],
<attrs generated init swh.scheduler.model.ListedOrigin>:18: in __init__
__attr_validator_last_update(self, __attr_last_update, self.last_update)
.tox/py3/lib/python3.7/site-packages/attr/_make.py:2723: in __call__
v(inst, attr, value)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:95: in _validator
_validate_elements(attribute, field, attribute.type)
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:123: in _validate_elements
_handle_union(attribute, value, expected_type)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
attribute = Attribute(name='last_update', default=None, validator=_AndValidator(_validators=(<function type_validator.<locals>._va...y({}), type=typing.Union[datetime.datetime, NoneType], converter=None, kw_only=False, inherited=False, on_setattr=None)
value = '2021-01-14T11:32:50.672Z'
expected_type = typing.Union[datetime.datetime, NoneType]
def _handle_union(attribute, value, expected_type):
union_has_none_type = any(
elem is None.__class__ for elem in expected_type.__args__
)
if value is None and union_has_none_type:
return
for arg in expected_type.__args__:
try:
_validate_elements(attribute, value, arg)
return
except ValueError:
pass
> raise UnionError(value, attribute.name, expected_type)
E attrs_strict._error.UnionError: Value of last_update 2021-01-14T11:32:50.672Z is not of type typing.Union[datetime.datetime, NoneType]
.tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:248: UnionError
TEST RESULT
TEST RESULT
- Run At
- Jan 25 2021, 6:39 PM