Skip to content

Commit

Permalink
Merge pull request #213 from chinapandaman/PPF-211
Browse files Browse the repository at this point in the history
PPF-211: forgot some tests
  • Loading branch information
chinapandaman authored May 1, 2021
2 parents e5ec61c + af1d222 commit c4d9329
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/v2/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ can be used out of box.

The most common tool to create a PDF form is Adobe Acrobat. A tutorial can be found
[here](https://helpx.adobe.com/acrobat/using/creating-distributing-pdf-forms.html).
There are other free alternatives like [sejda](https://www.sejda.com/) that support similar functionalities.
There are other free alternatives like [Sejda](https://www.sejda.com/) that support similar functionalities.

NOTE: Sejda is highly recommended as PyPDFForm
provides more stable support to PDF forms prepared using it with a `sejda` mode.
Expand Down
Binary file added pdf_samples/v2/sample_added_3_copies_sejda.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/functional/test_pdf_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,19 @@ def test_addition_operator_3_times(template_stream, pdf_samples, data_dict):
.split(MergeConstants().separator)[0]
in data_dict
)


def test_addition_operator_3_times_sejda(sejda_template, pdf_samples, sejda_data):
with open(os.path.join(pdf_samples, "sample_added_3_copies_sejda.pdf"), "rb+") as f:
result = PyPDFForm()
expected = f.read()

for i in range(3):
result += PyPDFForm(sejda_template, sejda=True).fill(sejda_data)

page_count = len(TemplateCore().get_elements_by_page(expected).keys())
result_page_count = len(
TemplateCore().get_elements_by_page(result.stream).keys()
)
assert page_count == result_page_count
assert result.read() == expected
5 changes: 5 additions & 0 deletions tests/unit/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def test_validate_template_stream(template_stream):
assert True


def test_remove_all_elements(template_stream):
result = TemplateCore().remove_all_elements(template_stream)
assert not TemplateCore().iterate_elements(result)


def test_iterate_elements_and_get_element_key(
template_with_radiobutton_stream, data_dict
):
Expand Down

0 comments on commit c4d9329

Please sign in to comment.