Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/tests/test_nixguix.py
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
def test_clean_sources_invalid_schema(swh_config, requests_mock_datadir): | def test_clean_sources_invalid_schema(swh_config, requests_mock_datadir): | ||||
sources = {} | sources = {} | ||||
with pytest.raises(ValueError, match="sources structure invalid, missing: .*"): | with pytest.raises(ValueError, match="sources structure invalid, missing: .*"): | ||||
clean_sources(sources) | clean_sources(sources) | ||||
def test_clean_sources_invalid_version(swh_config, requests_mock_datadir): | def test_clean_sources_invalid_version(swh_config, requests_mock_datadir): | ||||
sources = {"version": 2, "sources": [], "revision": "my-revision"} | for version_ok in [1, "1"]: # Check those versions are fine | ||||
clean_sources({"version": version_ok, "sources": [], "revision": "my-revision"}) | |||||
# but not version != 1 | |||||
for version_ko in [0, "0", 2, "2"]: # Check those versions are captured | |||||
vlorentz: s/are captured/raise an error/ | |||||
with pytest.raises( | with pytest.raises( | ||||
ValueError, match="sources structure version .* is not supported" | ValueError, match="sources structure version .* is not supported" | ||||
): | ): | ||||
clean_sources(sources) | clean_sources( | ||||
{"version": version_ko, "sources": [], "revision": "my-revision"} | |||||
) | |||||
def test_clean_sources_invalid_sources(swh_config, requests_mock_datadir): | def test_clean_sources_invalid_sources(swh_config, requests_mock_datadir): | ||||
sources = { | sources = { | ||||
"version": 1, | "version": 1, | ||||
"sources": [ | "sources": [ | ||||
# Valid source | # Valid source | ||||
{"type": "url", "urls": ["my-url"], "integrity": "my-integrity"}, | {"type": "url", "urls": ["my-url"], "integrity": "my-integrity"}, | ||||
▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines |
s/are captured/raise an error/