core/structure: help locate/extract gdpr exports (#175)
* core/structure: help locate/extract gdpr exports * ci: add install-types to install stub packages
This commit is contained in:
parent
8ca88bde2e
commit
821bc08a23
10 changed files with 192 additions and 2 deletions
BIN
tests/core/structure_data/gdpr_export.zip
Normal file
BIN
tests/core/structure_data/gdpr_export.zip
Normal file
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
test message
|
|
37
tests/core/test_structure.py
Normal file
37
tests/core/test_structure.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from my.core.structure import match_structure
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
def test_not_directory() -> None:
|
||||
with pytest.raises(NotADirectoryError, match=r"Expected either a zipfile or a directory"):
|
||||
with match_structure(
|
||||
structure_data / "messages/index.csv", expected=gdpr_expected
|
||||
):
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue