Skip to content

Commit

Permalink
PPF-779: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chinapandaman committed Dec 23, 2024
1 parent af2905a commit 1774970
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/scenario/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import os

from PyPDFForm import PdfWrapper
from PyPDFForm.middleware.radio import Radio
from PyPDFForm.template import get_widgets_by_page, get_widget_key
from PyPDFForm.constants import Parent, TU


def test_pdf_form_with_pages_without_widgets(issue_pdf_directory, request):
Expand Down Expand Up @@ -315,3 +318,19 @@ def test_get_desc_in_schema(issue_pdf_directory):
obj.schema["properties"]["P1_checkbox4[2]"]["description"]
== "Part 1. Information About You. Your Full Name. 4. Has your name legally changed since the issuance of your Permanent Resident Card? Select Not Applicable - I never received my previous card. (Proceed to Item Numbers 6. A. through 6. I.)."
) # noqa


def test_get_desc_in_schema_radio(issue_pdf_directory):
obj = PdfWrapper(os.path.join(issue_pdf_directory, "PPF-620.pdf"))

keys_to_check = []
for key, value in obj.widgets.items():
if isinstance(value, Radio) and value.desc is not None:
keys_to_check.append(key)

for widgets in get_widgets_by_page(obj.read()).values():
for widget in widgets:
key = get_widget_key(widget)

if key in keys_to_check:
assert widget[Parent][TU] == obj.schema["properties"][key]["description"] # noqa

0 comments on commit 1774970

Please sign in to comment.