File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# SPDX-License-Identifier: BSD-3-Clause
22# Copyright (c) 2026 Scipp contributors (https://github.com/scipp)
33
4- import hashlib
54from pathlib import Path
65
76import pooch
87
98from tof .facilities import _BASE_URLS , _source_library
109
1110
12- def sha256 (p : Path ) -> str :
13- h = hashlib .sha256 ()
14- with p .open ("rb" ) as f :
15- for chunk in iter (lambda : f .read (1024 * 1024 ), b"" ):
16- h .update (chunk )
17- return h .hexdigest ()
18-
19-
2011def test_source_library_files_identical_on_public_and_github (tmp_path : Path ) -> None :
2112 registry = {f ["path" ]: f ["hash" ] for f in _source_library .values ()}
2213
@@ -28,11 +19,14 @@ def test_source_library_files_identical_on_public_and_github(tmp_path: Path) ->
2819 path = tmp_path / "cache_github" , base_url = _BASE_URLS [1 ], registry = registry
2920 )
3021
31- for name , entry in _source_library .items ():
22+ for entry in _source_library .values ():
3223 rel = entry ["path" ]
3324
25+ # Verify that hashes are the same in both registries.
26+ assert public .registry [rel ] == gh .registry [rel ]
27+
3428 p_gh = Path (gh .fetch (rel ))
3529 p_public = Path (public .fetch (rel ))
3630
37- # registry already verifies md5, but we compare content across hosts:
38- assert sha256 ( p_gh ) == sha256 ( p_public ), f"Mismatch for { name } ( { rel } )"
31+ assert p_gh . stem == p_public . stem
32+ assert p_gh . suffix == p_public . suffix
You can’t perform that action at this time.
0 commit comments