This commit is contained in:
1 parent
ffe9e76a5b
commit
e9d6fb8207
9 files changed
+472
-16
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"""Tests for the local snapshot exporter."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
@@ -139,6 +140,21 @@ class ExportSnapshotTests(unittest.TestCase):
|
||||
exporter.write_snapshot(self.con, path, handle="tester")
|
||||
self.assertEqual(exporter.read_manifest(path)["user"]["handle"], "tester")
|
||||
|
||||
def test_checksum_matches_contract_framing(self):
|
||||
manifest, files = exporter.collect(self.con, handle="tester")
|
||||
digest = hashlib.sha256()
|
||||
for name in ("catalog.jsonl", "library.jsonl", "attributes.jsonl",
|
||||
"feedback.jsonl", "moods.json"):
|
||||
data = files.get(name)
|
||||
if data is None:
|
||||
continue
|
||||
digest.update(name.encode("utf-8"))
|
||||
digest.update(b"\0")
|
||||
digest.update(str(len(data)).encode("ascii"))
|
||||
digest.update(b"\0")
|
||||
digest.update(data)
|
||||
self.assertEqual(manifest["checksum_sha256"], digest.hexdigest())
|
||||
|
||||
|
||||
def export_snapshot_names(archive):
|
||||
return set(archive.namelist())
|
||||
|
||||
Reference in new issue
Block a user