diff --git a/resources/loader.yml b/resources/loader.yml new file mode 100644 index 0000000..0c9a3fe --- /dev/null +++ b/resources/loader.yml @@ -0,0 +1,3 @@ +storage: + cls: memory + args: {} diff --git a/swh/loader/package/tests/test_pypi.py b/swh/loader/package/tests/test_pypi.py index 5864b01..ea3dcb4 100644 --- a/swh/loader/package/tests/test_pypi.py +++ b/swh/loader/package/tests/test_pypi.py @@ -1,41 +1,53 @@ # Copyright (C) 2019 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import os +import pytest + +from swh.loader.package.pypi import PyPILoader + # scenario # configuration error # -# badly configured loader fails +def test_badly_configured_loader_raise(): + """Badly configured loader should raise""" + assert 'SWH_CONFIG_FILENAME' in os.environ # cf. tox.ini + del os.environ['SWH_CONFIG_FILENAME'] + with pytest.raises(ValueError) as e: + PyPILoader(url='some-url') + + assert 'Misconfiguration' in e.value.args[0] # "edge" cases (for the same origin) # # no release artifact: # {visit full, status: uneventful, no contents, etc...} # problem during loading: # {visit: partial, status: uneventful, no snapshot} # problem during loading: failure early enough in between swh contents... # some contents (contents, directories, etc...) have been written in storage # {visit: partial, status: eventful, no snapshot} # problem during loading: failure late enough we can have snapshots (some # revisions are written in storage already) # {visit: partial, status: eventful, snapshot} # "normal" cases (for the same origin) # # release artifact, no prior visit # {visit full, status eventful, snapshot} # release artifact, no new artifact # {visit full, status uneventful, same snapshot as before} # release artifact, new artifact # {visit full, status full, new snapshot with shared history as prior snapshot} # release artifact, old artifact with different checksums # {visit full, status full, new snapshot with shared history and some new # different history} diff --git a/tox.ini b/tox.ini index 0fb07c6..8e4539e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,18 @@ [tox] envlist=flake8,py3 [testenv:py3] deps = .[testing] pytest-cov +setenv = + SWH_CONFIG_FILENAME = ./resources/loader.yml commands = pytest --cov=swh --cov-branch {posargs} [testenv:flake8] skip_install = true deps = flake8 commands = {envpython} -m flake8