Accept single snippet photos and derive post IDs from titles
This commit is contained in:
@@ -266,6 +266,25 @@ def test_snippet_intake_validation_and_literal_text(service):
|
||||
assert client.post("/api/snippets", headers=AUTH, data={"photos": (io.BytesIO(b"bad"), "bad.jpg")}).status_code == 400
|
||||
|
||||
|
||||
def test_snippet_single_photo_alias(service):
|
||||
_, client, data = service
|
||||
raw = photo()
|
||||
response = client.post("/api/snippets", headers=AUTH, data={
|
||||
"photo": (io.BytesIO(raw), "photo.jpg"), "text": "A note",
|
||||
})
|
||||
assert response.status_code == 202, response.json
|
||||
assert response.json["count"] == 1
|
||||
assert (data / "submissions" / response.json["id"] / "originals/0").read_bytes() == raw
|
||||
duplicate = client.post("/api/snippets", headers=AUTH, data={
|
||||
"photos": (io.BytesIO(raw), "photo.jpg"), "text": "A note",
|
||||
})
|
||||
assert duplicate.json["id"] == response.json["id"]
|
||||
assert duplicate.status_code == 200
|
||||
assert client.post("/api/snippets", headers=AUTH, data={
|
||||
"photo": [(io.BytesIO(raw), "one.jpg"), (io.BytesIO(raw), "two.jpg")],
|
||||
}).status_code == 400
|
||||
|
||||
|
||||
def test_snippet_prepend_images_recovery_and_receipt(publisher, service, monkeypatch, tmp_path):
|
||||
run, remote, client = publisher
|
||||
_, _, data = service
|
||||
|
||||
Reference in New Issue
Block a user