| 1 |
import pytest |
| 2 |
|
| 3 |
from conda_package_handling import utils |
| 4 |
|
| 5 |
|
| 6 |
def test_checksum(tmp_path): |
| 7 |
tmp_file = tmp_path / "file" |
| 8 |
tmp_file.write_text("file") |
| 9 |
with tmp_file.open("rb") as f: |
| 10 |
with pytest.raises(ValueError): |
| 11 |
utils._checksum(f, "chicken") |
| 12 |
assert ( |
| 13 |
utils.sha256_checksum(f) |
| 14 |
== "3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80" |
| 15 |
) |
| 16 |
assert utils.md5_checksum(f) == "d41d8cd98f00b204e9800998ecf8427e" |
| 17 |
|
| 18 |
|
| 19 |
@pytest.mark.parametrize( |
| 20 |
"path", |
| 21 |
[ |
| 22 |
"info", |
| 23 |
"info/index.json", |
| 24 |
"info/files", |
| 25 |
"info/paths.json", |
| 26 |
"info/about.json", |
| 27 |
"info/has_prefix", |
| 28 |
"info/hash_input_files", |
| 29 |
"info/hash_input.json", |
| 30 |
"info/run_exports.yaml", |
| 31 |
"info/run_exports.json", |
| 32 |
"info/git", |
| 33 |
"info/recipe/meta.yaml", |
| 34 |
"info/recipe_log.json", |
| 35 |
"info/recipe.tar", |
| 36 |
"info/test/run_test.py", |
| 37 |
"info/LICENSE", |
| 38 |
"info/LICENSE.txt", |
| 39 |
"info/licenses/LICENSE", |
| 40 |
"info/requires", |
| 41 |
"info/meta", |
| 42 |
"info/platform", |
| 43 |
"info/no_link", |
| 44 |
"info/link.json", |
| 45 |
"info/icon.png", |
| 46 |
"info\\licenses\\LICENSE", |
| 47 |
"info\\index.json", |
| 48 |
], |
| 49 |
) |
| 50 |
def test_is_info_member_path(path): |
| 51 |
assert utils.is_info_member_path(path) |
| 52 |
|
| 53 |
|
| 54 |
@pytest.mark.parametrize( |
| 55 |
"path", |
| 56 |
[ |
| 57 |
"bin/foo", |
| 58 |
"lib/python3.10/site-packages/foo", |
| 59 |
"information/foo", |
| 60 |
"notinfo/foo", |
| 61 |
"infofoo/bar", |
| 62 |
"prefix/info/index.json", |
| 63 |
], |
| 64 |
) |
| 65 |
def test_is_info_member_path_false(path): |
| 66 |
assert not utils.is_info_member_path(path) |