-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added pdf meta data api tests #28
- Loading branch information
1 parent
a26a552
commit 5b5d12a
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)." | ||
} |