Skip to content

Commit

Permalink
Merge pull request #253 from chinapandaman/PPF-252
Browse files Browse the repository at this point in the history
PPF-252: scenario test - PDFescape
  • Loading branch information
chinapandaman authored Nov 14, 2021
2 parents 8d97263 + f453464 commit 0f8b920
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion PyPDFForm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
PyPDFForm = Wrapper
PyPDFForm2 = WrapperV2

__version__ = "1.0.1"
__version__ = "1.0.2"
File renamed without changes.
File renamed without changes.
Binary file added pdf_samples/scenario/tools/pdf_escape.pdf
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/functional/scenario/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ def pdf_directory():
return os.path.join(
os.path.dirname(__file__), "..", "..", "..", "pdf_samples", "scenario"
)


@pytest.fixture
def issue_pdf_directory(pdf_directory):
return os.path.join(pdf_directory, "issues")


@pytest.fixture
def tool_pdf_directory(pdf_directory):
return os.path.join(pdf_directory, "tools")
12 changes: 6 additions & 6 deletions tests/functional/scenario/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from PyPDFForm import PyPDFForm, PyPDFForm2


def test_pdf_form_with_pages_without_elements(pdf_directory):
obj = PyPDFForm2(os.path.join(pdf_directory, "PPF-246.pdf")).fill(
def test_pdf_form_with_pages_without_elements(issue_pdf_directory):
obj = PyPDFForm2(os.path.join(issue_pdf_directory, "PPF-246.pdf")).fill(
{"QCredit": "5000.63"}
)

with open(os.path.join(pdf_directory, "PPF-246-expected.pdf"), "rb+") as f:
with open(os.path.join(issue_pdf_directory, "PPF-246-expected.pdf"), "rb+") as f:
assert obj.read() == f.read()


def test_pdf_form_with_pages_without_elements_v1(pdf_directory):
def test_pdf_form_with_pages_without_elements_v1(issue_pdf_directory):
obj = PyPDFForm(
os.path.join(pdf_directory, "PPF-246.pdf"), simple_mode=False, sejda=True
os.path.join(issue_pdf_directory, "PPF-246.pdf"), simple_mode=False, sejda=True
).fill({"QCredit": "5000.63"})

with open(os.path.join(pdf_directory, "PPF-246-expected-v1.pdf"), "rb+") as f:
with open(os.path.join(issue_pdf_directory, "PPF-246-expected-v1.pdf"), "rb+") as f:
assert obj.read() == f.read()
22 changes: 22 additions & 0 deletions tests/functional/scenario/test_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

import os

from PyPDFForm import PyPDFForm2


def test_filling_pdf_escape_pdf_form(tool_pdf_directory):
with open(os.path.join(tool_pdf_directory, "pdf_escape_expected.pdf"), "rb+") as f:
assert PyPDFForm2(
os.path.join(tool_pdf_directory, "pdf_escape.pdf")
).fill(
{
"test_1": "test_1",
"test_2": "test_2",
"test_3": "test_3",
"check_1": True,
"check_2": True,
"check_3": True,
"radio_1": 2,
}
).read() == f.read()

0 comments on commit 0f8b920

Please sign in to comment.