Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/tests/test_nixguix.py
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | for version_ko in [0, "0", 2, "2"]: # Check version != 1 raise an error | ||||
ValueError, match="sources structure version .* is not supported" | ValueError, match="sources structure version .* is not supported" | ||||
): | ): | ||||
clean_sources( | clean_sources( | ||||
{"version": version_ko, "sources": [], "revision": "my-revision"} | {"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): | ||||
valid_sources = [ | |||||
# 1 valid source | |||||
{"type": "url", "urls": ["my-url.tar.gz"], "integrity": "my-integrity"}, | |||||
] | |||||
sources = { | sources = { | ||||
"version": 1, | "version": 1, | ||||
"sources": [ | "sources": valid_sources | ||||
# Valid source | + [ | ||||
{"type": "url", "urls": ["my-url"], "integrity": "my-integrity"}, | |||||
# integrity is missing | # integrity is missing | ||||
{"type": "url", "urls": ["my-url"],}, | {"type": "url", "urls": ["my-url.tgz"],}, | ||||
# urls is not a list | # urls is not a list | ||||
{"type": "url", "urls": "my-url", "integrity": "my-integrity"}, | {"type": "url", "urls": "my-url.zip", "integrity": "my-integrity"}, | ||||
# type is not url | # type is not url | ||||
{"type": "git", "urls": ["my-url"], "integrity": "my-integrity"}, | {"type": "git", "urls": ["my-url.zip"], "integrity": "my-integrity"}, | ||||
# missing fields which got double-checked nonetheless... | # missing fields which got double-checked nonetheless... | ||||
{"integrity": "my-integrity"}, | {"integrity": "my-integrity"}, | ||||
], | ], | ||||
"revision": "my-revision", | "revision": "my-revision", | ||||
} | } | ||||
clean = clean_sources(sources) | clean = clean_sources(sources) | ||||
assert len(clean["sources"]) == 1 | assert len(clean["sources"]) == len(valid_sources) | ||||
def test_clean_sources_unsupported_artifacts(swh_config, requests_mock_datadir): | |||||
supported_sources = [ | |||||
{ | |||||
"type": "url", | |||||
"urls": [f"https://server.org/my-url.{ext}"], | |||||
"integrity": "my-integrity", | |||||
} | |||||
vlorentz: missing `tbz2` | |||||
for ext in [ | |||||
"known-unknown-but-ok", # this is fine as well with the current approach | |||||
"zip", | |||||
"tar.gz", | |||||
"tgz", | |||||
"tar.bz2", | |||||
"tbz", | |||||
"tbz2", | |||||
"tar.xz", | |||||
"tar", | |||||
Not Done Inline Actionsmeh, I think we should support .patch eventually so it's not a great example. .whl and .iso would be better examples. but that's not a big deal vlorentz: meh, I think we should support `.patch` eventually so it's not a great example.
`.whl` and `. | |||||
Done Inline Actionsyes, agreed. ardumont: yes, agreed.
In the mean time, it's nice it's here.
That will fail when we'll add support and… | |||||
"zip", | |||||
"7z", | |||||
"Z", | |||||
] | |||||
] | |||||
unsupported_sources = [ | |||||
{ | |||||
"type": "url", | |||||
"urls": [f"https://server.org/my-url.{ext}"], | |||||
"integrity": "my-integrity", | |||||
} | |||||
for ext in [ | |||||
"iso", | |||||
"whl", | |||||
"gem", | |||||
"pom", | |||||
"msi", | |||||
"pod", | |||||
"png", | |||||
"rock", | |||||
"ttf", | |||||
"jar", | |||||
"c", | |||||
"rpm", | |||||
"diff", | |||||
"patch", | |||||
] | |||||
] | |||||
sources = { | |||||
"version": 1, | |||||
"sources": supported_sources + unsupported_sources, | |||||
"revision": "my-revision", | |||||
} | |||||
clean = clean_sources(sources) | |||||
assert len(clean["sources"]) == len(supported_sources) | |||||
def test_loader_one_visit(swh_config, requests_mock_datadir, raw_sources): | def test_loader_one_visit(swh_config, requests_mock_datadir, raw_sources): | ||||
loader = NixGuixLoader(sources_url) | loader = NixGuixLoader(sources_url) | ||||
res = loader.load() | res = loader.load() | ||||
assert res["status"] == "eventful" | assert res["status"] == "eventful" | ||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||
▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines |
missing tbz2