urls = ['https://crates.io/api/v1/0.1.5/no-extension-and-head-404-so-skipped']
request = <requests.sessions.Session object at 0x7f34f9a831d0>
def is_tarball(urls: List[str], request: Optional[Any] = None) -> Tuple[bool, str]:
"""Determine whether a list of files actually are tarballs or simple files.
When this cannot be answered simply out of the url, when request is provided, this
executes a HTTP `HEAD` query on the url to determine the information. If request is
not provided, this raises an ArtifactNatureUndetected exception.
Args:
urls: name of the remote files for which the extension needs to be checked.
Raises:
ArtifactNatureUndetected when the artifact's nature cannot be detected out
of its url
Returns: A tuple (bool, url). The boolean represents whether the url is an archive
or not. The second parameter is the actual url once the head request is issued
as a fallback of not finding out whether the urls are tarballs or not.
"""
def _is_tarball(url):
"""Determine out of an extension whether url is a tarball.
Raises:
IndexError in case no extension is available
"""
return Path(urlparse(url).path).suffixes[-1].lstrip(".") in TARBALL_EXTENSIONS
index = random.randrange(len(urls))
url = urls[index]
try:
> is_tar = _is_tarball(url)
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/lister.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://crates.io/api/v1/0.1.5/no-extension-and-head-404-so-skipped'
def _is_tarball(url):
"""Determine out of an extension whether url is a tarball.
Raises:
IndexError in case no extension is available
"""
> return Path(urlparse(url).path).suffixes[-1].lstrip(".") in TARBALL_EXTENSIONS
E IndexError: list index out of range
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/lister.py:126: IndexError
During handling of the above exception, another exception occurred:
datadir = '/var/lib/jenkins/workspace/DLS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/tests/data'
swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f34fa4a4be0>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f34fa497c18>
def test_lister_nixguix_mostly_noop(datadir, swh_scheduler, requests_mock):
"""NixGuixLister should ignore unsupported or incomplete origins"""
url = "https://guix.gnu.org/sources.json"
origin_upstream = "https://git.savannah.gnu.org/git/guix.git"
lister = NixGuixLister(swh_scheduler, url=url, origin_upstream=origin_upstream)
response = page_response(datadir, "guix")
requests_mock.get(
url,
[{"json": response}],
)
# Amongst artifacts, this url does not allow to determine its nature (tarball, file)
# It's ending up doing a http head query which ends up being 404, so it's skipped.
requests_mock.head(
"https://crates.io/api/v1/crates/proc-macro-crate/0.1.5/download",
status_code=404,
)
> listed_result = lister.run()
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/tests/test_lister.py:212:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:162: in run
for page in self.get_pages():
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/lister.py:300: in get_pages
is_tar, origin = is_tarball(urls, self.session)
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/lister.py:142: in is_tarball
response = request.head(url)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:622: in head
return self.request("HEAD", url, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:587: in request
resp = self.send(prep, **send_kwargs)
.tox/py3/lib/python3.7/site-packages/requests_mock/mocker.py:185: in _fake_send
return _original_send(session, request, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:701: in send
r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_mock.adapter.Adapter object at 0x7f34fa497be0>
request = <requests_mock.request._RequestObjectProxy object at 0x7f34f84b26d8>
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
matcher = <requests_mock.adapter._Matcher object at 0x7f34f8864320>, 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: HEAD https://crates.io/api/v1/0.1.5/no-extension-and-head-404-so-skipped
.tox/py3/lib/python3.7/site-packages/requests_mock/adapter.py:261: NoMockAddress
TEST RESULT
TEST RESULT
- Run At
- Oct 3 2022, 6:11 PM