feat: add Butler-mediated Paperless PDF import
This commit is contained in:
parent
b70a9a65ec
commit
fccd6db089
1 changed files with 35 additions and 0 deletions
|
|
@ -46,6 +46,41 @@ def test_health_exposes_current_version():
|
||||||
assert response.json()["version"] == app.VERSION == "2.3.5"
|
assert response.json()["version"] == app.VERSION == "2.3.5"
|
||||||
|
|
||||||
|
|
||||||
|
def test_paperless_import_queues_pdf_through_butler(monkeypatch):
|
||||||
|
captured = {}
|
||||||
|
|
||||||
|
def fake_upload(host, command, payload, timeout):
|
||||||
|
captured.update(host=host, command=command, payload=payload, timeout=timeout)
|
||||||
|
return 0, "", ""
|
||||||
|
|
||||||
|
monkeypatch.setattr(app, "_ssh_bytes", fake_upload)
|
||||||
|
pdf = b"%PDF-1.7\nvalid-test-payload"
|
||||||
|
with TestClient(app.app) as client:
|
||||||
|
response = client.post(
|
||||||
|
"/paperless/import?filename=Hausordnung%20Stand%2009.05.2022.pdf",
|
||||||
|
content=pdf,
|
||||||
|
headers={"Authorization": "Bearer test-token", "Content-Type": "application/pdf"},
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
body = response.json()
|
||||||
|
assert body["status"] == "queued"
|
||||||
|
assert body["filename"].startswith("Hausordnung_Stand_09.05.2022-")
|
||||||
|
assert captured["host"] == app.PAPERLESS_SSH
|
||||||
|
assert captured["payload"] == pdf
|
||||||
|
assert app.PAPERLESS_CONSUME_DIR in captured["command"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_paperless_import_rejects_non_pdf(monkeypatch):
|
||||||
|
monkeypatch.setattr(app, "_ssh_bytes", lambda *args: (_ for _ in ()).throw(AssertionError("must not upload")))
|
||||||
|
with TestClient(app.app) as client:
|
||||||
|
response = client.post(
|
||||||
|
"/paperless/import?filename=bad.pdf",
|
||||||
|
content=b"not a pdf",
|
||||||
|
headers={"Authorization": "Bearer test-token"},
|
||||||
|
)
|
||||||
|
assert response.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_ui_serves_self_contained_operator_console():
|
def test_ui_serves_self_contained_operator_console():
|
||||||
with TestClient(app.app) as client:
|
with TestClient(app.app) as client:
|
||||||
response = client.get("/ui")
|
response = client.get("/ui")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue