Skip to content

Commit

Permalink
feat: added pdf meta data api tests #28
Browse files Browse the repository at this point in the history
  • Loading branch information
rueedlinger committed Jun 2, 2024
1 parent a26a552 commit 5b5d12a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_api_pdf_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from starlette.testclient import TestClient

from teal import api
from tests import get_path


def test_pdf_extract_meta():
client = TestClient(api.app, raise_server_exceptions=False)
with open(get_path("data/digital_pdf/document_one_page.pdf"), "rb") as f:
response = client.post(url="/pdf/meta", files={"file": f})
assert response.status_code == 200
assert response.json()["fileName"] == "document_one_page.pdf"
assert response.json()["fileSize"] > 100
assert response.json()["pdfVersion"] == "1.3"
assert response.json()["pages"] == 1
assert response.json()["pdfaClaim"] is None
assert response.json()["docInfo"] is not None
assert response.json()["xmp"] is not None


def test_pdf_extract_meta_with_wrong_file_ending():
client = TestClient(api.app, raise_server_exceptions=False)
with open(get_path("data/doc/word_document.docx"), "rb") as f:
response = client.post(url="/pdf/text", files={"file": f})
assert response.status_code == 400
assert response.json() == {
"message": "file extension '.docx' is not supported (word_document.docx)."
}

0 comments on commit 5b5d12a

Please sign in to comment.