2019-12-30 13:09:18 +00:00
|
|
|
import hashlib
|
2020-01-31 13:35:21 +00:00
|
|
|
import json
|
2019-12-30 13:09:18 +00:00
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
2020-01-06 14:44:30 +00:00
|
|
|
def _hash_files(path):
|
|
|
|
files = path.iterdir()
|
2019-12-30 13:09:18 +00:00
|
|
|
hasher = hashlib.sha256()
|
|
|
|
for file in sorted(files):
|
2020-01-06 14:44:30 +00:00
|
|
|
hasher.update(file.read_bytes())
|
2019-12-30 13:09:18 +00:00
|
|
|
|
|
|
|
return hasher.digest().hex()
|
|
|
|
|
|
|
|
|
2020-03-04 12:33:34 +00:00
|
|
|
root = Path(__file__).parent / ".."
|
|
|
|
screens = root / "tests/ui_tests/screens"
|
|
|
|
fixtures = root / "tests/ui_tests/fixtures.json"
|
2019-12-30 13:09:18 +00:00
|
|
|
|
2020-01-31 13:35:21 +00:00
|
|
|
hashes = json.loads(fixtures.read_text())
|
|
|
|
|
|
|
|
for test_case in hashes.keys():
|
|
|
|
recorded_dir = screens / test_case / "recorded"
|
|
|
|
expected_hash = hashes[test_case]
|
2020-01-06 14:44:30 +00:00
|
|
|
actual_hash = _hash_files(recorded_dir)
|
|
|
|
assert expected_hash == actual_hash
|
2020-03-04 12:33:34 +00:00
|
|
|
shutil.make_archive(root / "ci/ui_test_records" / actual_hash, "zip", recorded_dir)
|