Skip to content

Commit

Permalink
feat: update libreoffice version (use debian backports) #25
Browse files Browse the repository at this point in the history
  • Loading branch information
rueedlinger committed Jun 6, 2024
1 parent b6785cb commit 603ff6e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions teal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def to_ocrmypdf_profile(self):


class LibreOfficePdfProfile(str, Enum):
PDFA_1a = "pdfa-1a"
PDFA_1B = "pdfa-1b"
PDFA_2B = "pdfa-2b"
PDFA_3B = "pdfa-3b"
PDF_15 = "pdf-1.5"
PDF_16 = "pdf-1.6"
# PDF17 = "pdf-1.7"
PDF17 = "pdf-1.7"

def to_libreoffice_pdf_version(self):
if "pdfa-" in self.value:
Expand Down
36 changes: 28 additions & 8 deletions tests/test_api_libreoffice_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_libreoffice_convert_docx_default():

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.6"
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] is None


Expand Down Expand Up @@ -65,6 +65,26 @@ def test_libreoffice_convert_docx_pdf16():
assert response.json()["pdfaClaim"] is None


def test_libreoffice_convert_docx_pdf17():
client = TestClient(api.app, raise_server_exceptions=False)
with open(get_path("data/doc/word_document.docx"), "rb") as f:
response = client.post(
url="/libreoffice/convert?profile=pdf-1.7", files={"file": f}
)
assert response.status_code == 200
with tempfile.NamedTemporaryFile(suffix=".pdf") as tmp:
tmp.write(response.content)
with open(tmp.name, "rb") as pdf_file:
response = client.post(url="/pdf/text", files={"file": pdf_file})
assert response.status_code == 200
assert len(response.json()) == 3

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] is None


def test_libreoffice_convert_txt_default():
client = TestClient(api.app, raise_server_exceptions=False)
with open(get_path("data/doc/text_document.txt"), "rb") as f:
Expand All @@ -79,7 +99,7 @@ def test_libreoffice_convert_txt_default():

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.6"
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] is None


Expand All @@ -97,7 +117,7 @@ def test_libreoffice_convert_pdf_default():

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.6"
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] is None


Expand Down Expand Up @@ -131,7 +151,7 @@ def test_libreoffice_convert_pdfa1():
client = TestClient(api.app, raise_server_exceptions=False)
with open(get_path("data/doc/word_document.docx"), "rb") as f:
response = client.post(
url="/libreoffice/convert?profile=pdfa-1a", files={"file": f}
url="/libreoffice/convert?profile=pdfa-1b", files={"file": f}
)
assert response.status_code == 200
with tempfile.NamedTemporaryFile(suffix=".pdf") as tmp:
Expand All @@ -140,12 +160,12 @@ def test_libreoffice_convert_pdfa1():
response = client.post(url="/pdfa/validate", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["compliant"] is True
assert response.json()["profile"] == "PDF/A-1A"
assert response.json()["profile"] == "PDF/A-1B"

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.4"
assert response.json()["pdfaClaim"] == "1A"
assert response.json()["pdfaClaim"] == "1B"


def test_libreoffice_convert_pdfa2():
Expand All @@ -165,7 +185,7 @@ def test_libreoffice_convert_pdfa2():

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.6"
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] == "2B"


Expand All @@ -186,7 +206,7 @@ def test_libreoffice_convert_pdfa3():

response = client.post(url="/pdf/meta", files={"file": pdf_file})
assert response.status_code == 200
assert response.json()["pdfVersion"] == "1.6"
assert response.json()["pdfVersion"] == "1.7"
assert response.json()["pdfaClaim"] == "3B"


Expand Down
4 changes: 2 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


def test_libreoffice_pdf_profile_model():
# assert LibreOfficePdfProfile.PDF17.to_libreoffice_pdf_version() == "17"
assert LibreOfficePdfProfile.PDF17.to_libreoffice_pdf_version() == "17"
assert LibreOfficePdfProfile.PDF_16.to_libreoffice_pdf_version() == "16"
assert LibreOfficePdfProfile.PDF_15.to_libreoffice_pdf_version() == "15"
assert LibreOfficePdfProfile.PDFA_1a.to_libreoffice_pdf_version() == "1"
assert LibreOfficePdfProfile.PDFA_1B.to_libreoffice_pdf_version() == "1"
assert LibreOfficePdfProfile.PDFA_2B.to_libreoffice_pdf_version() == "2"
assert LibreOfficePdfProfile.PDFA_3B.to_libreoffice_pdf_version() == "3"

Expand Down

0 comments on commit 603ff6e

Please sign in to comment.