1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
"""
Deleting a photo from the Photos app (harness/photo_delete_probe.py).
On a right-clicked tile and in the lightbox's bar, which is how a phone gets
at it. Offered on the rule Files applies and the node enforces: the node's
operator, or whoever uploaded the photo. Never without the page's own
confirmation, and never from Search, which is read-only.
"""
import json
import shutil
import subprocess
import sys
from pathlib import Path
import pytest
HARNESS = Path(__file__).parent / "harness" / "photo_delete_probe.py"
@pytest.fixture(scope="module")
def cases():
if shutil.which("google-chrome") is None:
pytest.skip("Chrome is not available")
proc = subprocess.run([sys.executable, str(HARNESS)],
capture_output=True, text=True, timeout=180)
assert proc.returncode == 0, f"probe failed: {proc.stdout}{proc.stderr}"
out = json.loads(proc.stdout)
assert "error" not in out, out["error"]
assert out["logs"] == []
return {c["case"]: c for c in out["cases"]}
def test_ones_own_photo_is_deleted_only_once_confirmed(cases):
c = cases["tile"]
assert "Delete" in c["labels"]
assert c["asked"].startswith("Delete beach.jpg?")
assert c["after_no"] == {"deleted": 0, "tiles": 3}
assert c["deleted"] == [["p1", "sign-fn"]]
assert c["tiles"] == 2
def test_somebody_elses_photo_offers_no_delete(cases):
assert "Delete" not in cases["not mine"]["menu_without_delete"]
def test_the_operator_may_delete_any_photo(cases):
assert cases["operator"]["delete_offered"] == [True, True, True]
def test_the_lightbox_deletes_and_shows_the_next_photo(cases):
c = cases["lightbox"]
assert c["button"] and c["dialog_on_top"]
assert c["deleted"] == ["p1"]
assert c["open"] and c["before"] == "beach.jpg" and c["after"] == "dunes.jpg"
def test_search_results_offer_no_delete(cases):
c = cases["read only"]
assert "Delete" not in c["labels"] and not c["lightbox_button"]
|