-
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 endpoint (#31)
* fix: move metrics to appinfo tag * feat: added pdf meta data endpoint #28 * feat: added pdf meta data api tests #28
- Loading branch information
1 parent
ef1ab1c
commit cbb3654
Showing
8 changed files
with
201 additions
and
3 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 |
---|---|---|
|
@@ -13,6 +13,7 @@ ghostscript | |
# needed by camelot-py | ||
opencv-python | ||
PyPDF2 | ||
pikepdf | ||
pytest | ||
pytest-cov | ||
locust | ||
|
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
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
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
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
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
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)." | ||
} |
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