Spaces:
Running
Running
| """Privacy and no-persistence regression tests.""" | |
| from PIL import Image | |
| import app | |
| def test_lookup_species_does_not_record_history_or_exportable_user_inputs(): | |
| result = app.lookup_species( | |
| "lingcod", | |
| "Thinking of harvest", | |
| "Point Arena to Pigeon Point", | |
| "Pacifica", | |
| ) | |
| assert not hasattr(app, "LOOKUP_HISTORY") | |
| assert "county_or_beach" not in result | |
| assert "Pacifica" not in str(result) | |
| def test_photo_candidate_result_is_session_only_and_retains_no_image_data(): | |
| result = app.lookup_photo_candidate(Image.new("RGB", (64, 64), (25, 25, 30))) | |
| assert result["image_retained"] is False | |
| assert "image" not in result | |
| assert "photo" not in result | |
| assert not hasattr(app, "PHOTO_HISTORY") | |
| def test_rendered_ui_copy_does_not_offer_save_export_or_history_actions(): | |
| markdown = app.render_lookup_result( | |
| "lingcod", | |
| "Just curious", | |
| "Point Arena to Pigeon Point", | |
| "", | |
| ).casefold() | |
| assert "save" not in markdown | |
| assert "export" not in markdown | |
| assert "history" not in markdown | |
| def test_source_backed_question_location_and_wording_are_session_only(): | |
| result = app.ask_source_backed_question("what's the min size of lingcod?", "Pacifica") | |
| markdown = app.render_source_backed_answer("what's the min size of lingcod?", "Pacifica").casefold() | |
| assert result["matched_place"] == "Pacifica" | |
| assert "session-only" in markdown | |
| assert "questions and optional locations are not saved" in markdown | |
| assert not hasattr(app, "SOURCE_BACKED_QUESTION_HISTORY") | |
| assert not hasattr(app, "SOURCE_BACKED_LOCATION_HISTORY") | |
| assert not hasattr(app, "GENERATED_ANSWER_HISTORY") | |
| def test_source_backed_controls_do_not_offer_account_save_export_history_or_photo_core(): | |
| labels = " ".join(app.SOURCE_BACKED_CONTROL_LABELS).casefold() | |
| for forbidden in ("account", "save", "export", "history", "photo", "camera"): | |
| assert forbidden not in labels | |