Merge photo highlights by name and capture year

This commit is contained in:
2026-09-26 19:38:15 +01:00
parent 41c637eca9
commit d15ba78579
47 changed files with 221 additions and 9 deletions
+50
View File
@@ -379,6 +379,56 @@ def test_publisher_names_photo_entry_from_capture_date(publisher, service):
assert f'_art/2025-04-18-photo-{response.json["id"]}-00.md' in paths
def test_publisher_merges_highlights_by_name_and_capture_year(publisher):
run, remote, client = publisher
first = client.post("/api/photos", headers=AUTH, data={
"photos": [(io.BytesIO(photo("red")), "first.jpg")],
"highlight": "Trip", "photo_dates": "2026-03-01T12:00:00+00:00",
}).json["id"]
assert run().returncode == 0
second = client.post("/api/photos", headers=AUTH, data={
"photos": [(io.BytesIO(photo("blue")), "second.jpg")],
"highlight": "Trip", "photo_dates": "2026-06-01T12:00:00+00:00",
}).json["id"]
assert run().returncode == 0
files = git(remote, "ls-tree", "-r", "--name-only", "master").splitlines()
entries = [git(remote, "show", f"master:{path}") for path in files if path.startswith("_art/")]
assert sum('anchor: "Trip"' in entry for entry in entries) == 1
assert f'anchor: "Trip"' in next(entry for entry in entries if f"photo-{second}" in entry)
assert f'<div id="photo-{first}"></div>' in next(
entry for entry in entries if f'title: "photo-{first}"' in entry)
old_year = client.post("/api/photos", headers=AUTH, data={
"photos": [(io.BytesIO(photo("green")), "old-year.jpg")],
"highlight": "Trip", "photo_dates": "2025-12-31T12:00:00+00:00",
}).json["id"]
assert run().returncode == 0
files = git(remote, "ls-tree", "-r", "--name-only", "master").splitlines()
entries = [git(remote, "show", f"master:{path}") for path in files if path.startswith("_art/")]
assert sum('anchor: "Trip"' in entry for entry in entries) == 2
assert 'anchor: "Trip"' in next(entry for entry in entries if f"photo-{old_year}" in entry)
commit = git(remote, "rev-parse", "master")
assert run().returncode == 0
assert git(remote, "rev-parse", "master") == commit
def test_publisher_splits_a_highlight_across_capture_years(publisher):
run, remote, client = publisher
response = client.post("/api/photos", headers=AUTH, data={
"photos": [(io.BytesIO(photo("red")), "old.jpg"),
(io.BytesIO(photo("blue")), "new.jpg")],
"highlight": "Trip",
"photo_dates": "2025-12-31T12:00:00+00:00\n2026-01-01T12:00:00+00:00",
})
assert response.status_code == 202
result = run()
assert result.returncode == 0, result.stderr
job = response.json["id"]
files = git(remote, "ls-tree", "-r", "--name-only", "master").splitlines()
entries = [git(remote, "show", f"master:{path}") for path in files if f"photo-{job}" in path]
assert len(entries) == 2
assert all('anchor: "Trip"' in entry for entry in entries)
def test_publisher_replaces_an_undated_version_of_the_same_photos(publisher, service):
run, remote, client = publisher
raw = photo()