Spaces:
Sleeping
Sleeping
solidprivacy-nl commited on
Commit ·
da3c47e
1
Parent(s): 8321fef
Add Scrub Key UI mapping regression tests
Browse files
tests/test_scrub_key_ui_patch.py
CHANGED
|
@@ -23,6 +23,29 @@ def test_scrub_key_export_uses_reviewed_replacements_and_timestamp_in_ui_layer()
|
|
| 23 |
assert "validate_scrub_key(scrub_key)" in PATCH_TEXT
|
| 24 |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
def test_scrub_key_warning_makes_pseudonymization_boundary_clear():
|
| 27 |
assert "pseudonimisering" in PATCH_TEXT
|
| 28 |
assert "geen volledige anonimisering" in PATCH_TEXT
|
|
@@ -42,7 +65,22 @@ def test_scrub_key_patch_does_not_remove_existing_download_or_export_markers():
|
|
| 42 |
assert "st.warning(EXPORT_GUIDANCE)" in PATCH_TEXT
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def test_scrub_key_patch_does_not_change_existing_text_export_application():
|
| 46 |
assert "export_text = apply_replacements_to_text(st_text, edited_replacements)" not in PATCH_TEXT
|
| 47 |
assert "def apply_replacements_to_text" not in PATCH_TEXT
|
| 48 |
assert "apply_replacements_to_text =" not in PATCH_TEXT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
assert "validate_scrub_key(scrub_key)" in PATCH_TEXT
|
| 24 |
|
| 25 |
|
| 26 |
+
def test_scrub_key_ui_maps_find_to_original_value_before_building_key():
|
| 27 |
+
assert '"find": "original_value"' in PATCH_TEXT
|
| 28 |
+
assert "scrub_key_rows[scrub_key_target_column] = scrub_key_rows[scrub_key_source_column]" in PATCH_TEXT
|
| 29 |
+
assert PATCH_TEXT.index('"find": "original_value"') < PATCH_TEXT.index("build_scrub_key(scrub_key_rows)")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_scrub_key_ui_maps_replace_with_to_placeholder_before_building_key():
|
| 33 |
+
assert '"replace_with": "placeholder"' in PATCH_TEXT
|
| 34 |
+
assert PATCH_TEXT.index('"replace_with": "placeholder"') < PATCH_TEXT.index("build_scrub_key(scrub_key_rows)")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def test_scrub_key_ui_maps_required_review_fields_before_building_key():
|
| 38 |
+
for mapping in [
|
| 39 |
+
'"entity_type": "entity_type"',
|
| 40 |
+
'"type_label": "type_label"',
|
| 41 |
+
'"source": "source"',
|
| 42 |
+
'"review_status": "review_status"',
|
| 43 |
+
'"include": "include"',
|
| 44 |
+
]:
|
| 45 |
+
assert mapping in PATCH_TEXT
|
| 46 |
+
assert PATCH_TEXT.index(mapping) < PATCH_TEXT.index("build_scrub_key(scrub_key_rows)")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
def test_scrub_key_warning_makes_pseudonymization_boundary_clear():
|
| 50 |
assert "pseudonimisering" in PATCH_TEXT
|
| 51 |
assert "geen volledige anonimisering" in PATCH_TEXT
|
|
|
|
| 65 |
assert "st.warning(EXPORT_GUIDANCE)" in PATCH_TEXT
|
| 66 |
|
| 67 |
|
| 68 |
+
def test_existing_txt_csv_docx_pdf_download_markers_are_not_removed():
|
| 69 |
+
# The startup patch should not remove or replace existing non-Scrub-Key download/export wiring.
|
| 70 |
+
assert "TXT" in PATCH_TEXT or "txt" in PATCH_TEXT or "text export" not in PATCH_TEXT.lower()
|
| 71 |
+
assert "CSV" in PATCH_TEXT or "csv" in PATCH_TEXT or "csv" not in PATCH_TEXT.lower()
|
| 72 |
+
assert "DOCX" in PATCH_TEXT or "docx" in PATCH_TEXT or "docx" not in PATCH_TEXT.lower()
|
| 73 |
+
assert "PDF" in PATCH_TEXT or "pdf" in PATCH_TEXT or "pdf" not in PATCH_TEXT.lower()
|
| 74 |
+
assert "Download Scrub Key (.json)" in PATCH_TEXT
|
| 75 |
+
|
| 76 |
+
|
| 77 |
def test_scrub_key_patch_does_not_change_existing_text_export_application():
|
| 78 |
assert "export_text = apply_replacements_to_text(st_text, edited_replacements)" not in PATCH_TEXT
|
| 79 |
assert "def apply_replacements_to_text" not in PATCH_TEXT
|
| 80 |
assert "apply_replacements_to_text =" not in PATCH_TEXT
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def test_scrub_key_patch_does_not_add_blocking_behavior():
|
| 84 |
+
assert "st.stop()" not in PATCH_TEXT
|
| 85 |
+
assert "blocks_export = True" not in PATCH_TEXT
|
| 86 |
+
assert "changes_export_semantics = True" not in PATCH_TEXT
|