File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: BSD-3-Clause
2+ # Copyright (c) 2026 Scipp contributors (https://github.com/scipp)
3+
4+ import hashlib
5+ from pathlib import Path
6+
7+ import pooch
8+
9+ from tof .facilities import _BASE_URLS , _source_library
10+
11+
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+
20+ def test_source_library_files_identical_on_public_and_github (tmp_path : Path ) -> None :
21+ registry = {f ["path" ]: f ["hash" ] for f in _source_library .values ()}
22+
23+ public = pooch .create (
24+ path = tmp_path / "cache_public" , base_url = _BASE_URLS [0 ], registry = registry
25+ )
26+
27+ gh = pooch .create (
28+ path = tmp_path / "cache_github" , base_url = _BASE_URLS [1 ], registry = registry
29+ )
30+
31+ for name , entry in _source_library .items ():
32+ rel = entry ["path" ]
33+
34+ p_gh = Path (gh .fetch (rel ))
35+ p_public = Path (public .fetch (rel ))
36+
37+ # registry already verifies md5, but we compare content across hosts:
38+ assert sha256 (p_gh ) == sha256 (p_public ), f"Mismatch for { name } ({ rel } )"
You can’t perform that action at this time.
0 commit comments