bookwyrm/bookwyrm/tests/utils/test_tar.py
CSDUMMI 688978369f Implement self-contained archives to import and export entire users between instances (#38)
Co-authored-by: Daniel Burgess <developerdannymate@gmail.com>
Co-authored-by: Hugh Rundle <hugh@hughrundle.net>
Co-authored-by: dannymate <dannymate@noreply.codeberg.org>
Co-authored-by: hughrun <hughrun@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/GuildAlpha/bookwyrm/pulls/38
Co-authored-by: CSDUMMI <csdummi.misquality@simplelogin.co>
Co-committed-by: CSDUMMI <csdummi.misquality@simplelogin.co>
2023-09-07 22:37:28 +02:00

24 lines
642 B
Python

from bookwyrm.utils.tar import BookwyrmTarFile
import pytest
@pytest.fixture
def read_tar():
archive_path = "../data/bookwyrm_account_export.tar.gz"
with open(archive_path, "rb") as archive_file:
with BookwyrmTarFile.open(mode="r:gz", fileobj=archive_file) as tar:
yield tar
def get_write_tar():
archive_path = "/tmp/test.tar.gz"
with open(archive_path, "wb") as archive_file:
with BookwyrmTarFile.open(mode="w:gz", fileobj=archive_file) as tar:
return tar
os.remove(archive_path)
def test_write_bytes(write_tar):
write_tar.write_bytes(b"ABCDEF", filename="example.txt")