(key)
| 19 | |
| 20 | |
| 21 | def 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 | |
| 44 | def test_format_parse_roundtrip_borg1(key): # legacy |
nothing calls this directly
no test coverage detected