Skip to content

Commit

Permalink
test: Use netlocs that are known to not exist or give known return (#…
Browse files Browse the repository at this point in the history
…1651)

* Use netloc of www.pyhfthisdoesnotexist.org which is known to not exist
to test not an approved archive host
* Use https://httpstat.us/404/ to provide a valid URL that exists but
which does not contain a valid file
   - c.f. https://httpstat.us/
  • Loading branch information
matthewfeickert authored Oct 18, 2021
1 parent 2275660 commit fb3a727
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,19 +553,18 @@ def test_patchset_download(tmpdir, script_runner, archive):
ret = script_runner.run(*shlex.split(command))
assert ret.success

command = f'pyhf contrib download --verbose https://www.fail.org/record/resource/1234567 {tmpdir.join("likelihoods").strpath}'
command = f'pyhf contrib download --verbose https://www.pyhfthisdoesnotexist.org/record/resource/1234567 {tmpdir.join("likelihoods").strpath}'
ret = script_runner.run(*shlex.split(command))
assert not ret.success
assert (
"pyhf.exceptions.InvalidArchiveHost: www.fail.org is not an approved archive host"
"pyhf.exceptions.InvalidArchiveHost: www.pyhfthisdoesnotexist.org is not an approved archive host"
in ret.stderr
)
command = f'pyhf contrib download --verbose --force https://www.fail.org/record/resource/1234567 {tmpdir.join("likelihoods").strpath}'
# Force a download from a real URL, but one that doesn't have an existing file
command = f'pyhf contrib download --verbose --force https://httpstat.us/404/record/resource/1234567 {tmpdir.join("likelihoods").strpath}'
ret = script_runner.run(*shlex.split(command))
assert not ret.success
assert (
"SSLCertificateError" and "hostname 'www.fail.org' doesn't match" in ret.stderr
)
assert "tarfile.ReadError: not a gzip file" in ret.stderr


def test_missing_contrib_extra(caplog):
Expand Down

0 comments on commit fb3a727

Please sign in to comment.