core/structure: help locate/extract gdpr exports

This commit is contained in:
Sean Breckenridge 2021-07-01 06:29:32 -07:00
parent 8ca88bde2e
commit e065145162
8 changed files with 179 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1 @@
test message
1 test message

View file

@ -0,0 +1,27 @@
from my.core.structure import match_structure
from pathlib import Path
structure_data: Path = Path(__file__).parent / "structure_data"
gdpr_expected = ("comments", "messages/index.csv", "profile")
def test_gdpr_structure_exists() -> None:
with match_structure(structure_data, expected=gdpr_expected) as results:
assert results == (structure_data / "gdpr_subdirs" / "gdpr_export",)
def test_gdpr_unzip() -> None:
with match_structure(
structure_data / "gdpr_export.zip", expected=gdpr_expected
) as results:
assert len(results) == 1
extracted = results[0]
index_file = extracted / "messages" / "index.csv"
assert index_file.read_text().strip() == "test message"
# make sure the temporary directory this created no longer exists
assert not extracted.exists()