Skip to content

Commit

Permalink
Merge pull request #653 from chinapandaman/PPF-649
Browse files Browse the repository at this point in the history
PPF-649: add more tests for Adobe mode
  • Loading branch information
chinapandaman authored Jun 15, 2024
2 parents d569387 + 9f06732 commit 1e4bad9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Binary file added pdf_samples/adobe_mode/dropdown/dropdown_one.pdf
Binary file not shown.
Binary file added pdf_samples/adobe_mode/issues/613_expected.pdf
Binary file not shown.
Binary file added pdf_samples/scenario/issues/613.pdf
Binary file not shown.
48 changes: 48 additions & 0 deletions tests/test_adobe_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@
from PyPDFForm import FormWrapper


def test_dropdown_one(sample_template_with_dropdown, pdf_samples, request):
expected_path = os.path.join(pdf_samples, "adobe_mode", "dropdown", "dropdown_one.pdf")
with open(expected_path, "rb+") as f:
obj = FormWrapper(sample_template_with_dropdown).fill(
{
"test_1": "test_1",
"test_2": "test_2",
"test_3": "test_3",
"check_1": True,
"check_2": True,
"check_3": True,
"radio_1": 1,
"dropdown_1": 0,
},
adobe_mode=True,
)

request.config.results["expected_path"] = expected_path
request.config.results["stream"] = obj.read()

expected = f.read()

assert len(obj.read()) == len(expected)
assert obj.stream == expected


def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request):
expected_path = os.path.join(
pdf_samples, "adobe_mode", "paragraph", "sample_filled_sejda_complex.pdf"
Expand Down Expand Up @@ -43,3 +69,25 @@ def test_fill_sejda_complex(sejda_template_complex, pdf_samples, request):

assert len(obj.read()) == len(expected)
assert obj.stream == expected


def test_issue_613(pdf_samples, request):
expected_path = os.path.join(pdf_samples, "adobe_mode", "issues", "613_expected.pdf")
with open(expected_path, "rb+") as f:
obj = FormWrapper(
os.path.join(pdf_samples, "scenario", "issues", "613.pdf")
).fill(
{
"301 Full name": "John Smith",
"301 Address Street": "1234 road number 6",
},
adobe_mode=True,
)

request.config.results["expected_path"] = expected_path
request.config.results["stream"] = obj.read()

expected = f.read()

assert len(obj.read()) == len(expected)
assert obj.stream == expected

0 comments on commit 1e4bad9

Please sign in to comment.