MCPcopy
hub / github.com/borgbackup/borg / test_format_parse_roundtrip

Function test_format_parse_roundtrip

src/borg/testsuite/repoobj_test.py:21–41  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

19
20
21def test_format_parse_roundtrip(key):
22 repo_objs = RepoObj(key)
23 data = b"foobar" * 10
24 id = repo_objs.id_hash(data)
25 meta = {"custom": "something"} # size and csize are computed automatically
26 cdata = repo_objs.format(id, meta, data, ro_type=ROBJ_FILE_STREAM)
27
28 got_meta = repo_objs.parse_meta(id, cdata, ro_type=ROBJ_FILE_STREAM)
29 assert got_meta["size"] == len(data)
30 assert got_meta["csize"] < len(data)
31 assert got_meta["custom"] == "something"
32
33 got_meta, got_data = repo_objs.parse(id, cdata, ro_type=ROBJ_FILE_STREAM)
34 assert got_meta["size"] == len(data)
35 assert got_meta["csize"] < len(data)
36 assert got_meta["custom"] == "something"
37 assert data == got_data
38
39 edata = repo_objs.extract_crypted_data(cdata)
40 key = repo_objs.key
41 assert edata.startswith(bytes((key.TYPE,)))
42
43
44def test_format_parse_roundtrip_borg1(key): # legacy

Callers

nothing calls this directly

Calls 6

id_hashMethod · 0.95
formatMethod · 0.95
parse_metaMethod · 0.95
parseMethod · 0.95
extract_crypted_dataMethod · 0.95
RepoObjClass · 0.85

Tested by

no test coverage detected