swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7fb9cbf3ae48>
requests_mock = <requests_mock.mocker.Mocker object at 0x7fb9cbf3a390>
maven_index_full = b'doc 0\n field 0\n name u\n type string\n value al.aldi|sprova4j|0.1.0|sources|jar\n field 1\n name m\n...otGroups\n field 19\n name rootGroupsList\n type string\n value com|al\nEND\nchecksum 00000000004102281591\n'
maven_index_incr_first = b'doc 0\n field 0\n name u\n type string\n value al.aldi|sprova4j|0.1.0|sources|jar\n field 1\n name m\n...tring\n value sprova4j\n field 11\n name d\n type string\n value Java client for Sprova Test Management\n'
def test_maven_incremental_listing(
swh_scheduler,
requests_mock,
maven_index_full,
maven_index_incr_first,
):
"""Covers full listing of multiple pages, checking page results and listed
origins, with a second updated run for statefulness."""
lister = MavenLister(
scheduler=swh_scheduler,
url=MVN_URL,
instance="maven.org",
index_url=INDEX_URL,
incremental=True,
)
# Set up test.
requests_mock.get(INDEX_URL, content=maven_index_incr_first)
# Then run the lister.
stats = lister.run()
# Start test checks.
assert lister.incremental
assert lister.updated
assert stats.pages == 2
scheduler_origins = swh_scheduler.get_listed_origins(lister.lister_obj.id).results
origin_urls = [origin.url for origin in scheduler_origins]
# 1 git origins + 1 maven origin with 1 release (one per jar)
assert len(origin_urls) == 2
assert sorted(origin_urls) == sorted((LIST_GIT[0],) + LIST_SRC)
for origin in scheduler_origins:
if origin.visit_type == "maven":
last_update_src = iso8601.parse_date(LIST_SRC_DATA[0]["time"])
assert last_update_src == origin.last_update
assert origin.extra_loader_arguments["artifacts"] == [LIST_SRC_DATA[0]]
# Second execution of the lister, incremental mode
lister = MavenLister(
scheduler=swh_scheduler,
url=MVN_URL,
instance="maven.org",
index_url=INDEX_URL,
incremental=True,
)
scheduler_state = lister.get_state_from_scheduler()
assert scheduler_state is not None
assert scheduler_state.last_seen_doc == 1
assert scheduler_state.last_seen_pom == 1
# Set up test.
requests_mock.get(INDEX_URL, content=maven_index_full)
# Then run the lister.
> stats = lister.run()
.tox/py3/lib/python3.7/site-packages/swh/lister/maven/tests/test_lister.py:241:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:130: in run
full_stats.origins += self.send_origins(origins)
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:233: in send_origins
for batch_origins in grouper(origins, n=1000):
.tox/py3/lib/python3.7/site-packages/swh/core/utils.py:53: in grouper
for _data in itertools.zip_longest(*args, fillvalue=stop_value):
.tox/py3/lib/python3.7/site-packages/swh/lister/maven/lister.py:326: in get_origins_from_page
listed_origin = self.get_scm(page)
.tox/py3/lib/python3.7/site-packages/swh/lister/maven/lister.py:311: in get_scm
url = self.github_session.get_canonical_url(url)
.tox/py3/lib/python3.7/site-packages/swh/core/github/utils.py:226: in get_canonical_url
response = self.request(_url_github_api(user_repo))
.tox/py3/lib/python3.7/site-packages/swh/core/github/utils.py:176: in request
return self._request(url)
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:324: in wrapped_f
return self(f, *args, **kw)
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:404: in __call__
do = self.iter(retry_state=retry_state)
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:349: in iter
return fut.result()
/usr/lib/python3.7/concurrent/futures/_base.py:425: in result
return self.__get_result()
/usr/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:407: in __call__
result = fn(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/core/github/utils.py:148: in _request
response = self.session.get(url)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:542: in get
return self.request('GET', url, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:529: in request
resp = self.send(prep, **send_kwargs)
.tox/py3/lib/python3.7/site-packages/requests_mock/mocker.py:144: in _fake_send
return _original_send(session, request, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:645: in send
r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_mock.adapter.Adapter object at 0x7fb9cbf3aa90>
request = <requests_mock.request._RequestObjectProxy object at 0x7fb9cbf3a748>
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
matcher = <requests_mock.adapter._Matcher object at 0x7fb9cbf3abe0>, resp = None
def send(self, request, **kwargs):
request = _RequestObjectProxy(request,
case_sensitive=self._case_sensitive,
**kwargs)
self._add_to_history(request)
for matcher in reversed(self._matchers):
try:
resp = matcher(request)
except Exception:
request._matcher = weakref.ref(matcher)
raise
if resp is not None:
request._matcher = weakref.ref(matcher)
resp.connection = self
logger.debug('{} {} {}'.format(request._request.method,
request._request.url,
resp.status_code))
return resp
> raise exceptions.NoMockAddress(request)
E requests_mock.exceptions.NoMockAddress: No mock address: GET https://api.github.com/repos/aldialimucaj/sprova4j
.tox/py3/lib/python3.7/site-packages/requests_mock/adapter.py:261: NoMockAddress
TEST RESULT
TEST RESULT
- Run At
- May 20 2022, 4:42 PM