Skip to content

Commit

Permalink
PPF-463: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chinapandaman committed Jan 25, 2024
1 parent 2794169 commit ed7aae1
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
Binary file added pdf_samples/widget/create_checkbox_check.pdf
Binary file not shown.
Binary file added pdf_samples/widget/create_checkbox_circle.pdf
Binary file not shown.
Binary file added pdf_samples/widget/create_checkbox_cross.pdf
Binary file not shown.
72 changes: 72 additions & 0 deletions tests/test_create_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,78 @@ def test_create_checkbox_complex(template_stream, pdf_samples, request):
assert obj.stream == expected


def test_create_checkbox_check(template_stream, pdf_samples, request):
expected_path = os.path.join(
pdf_samples, "widget", "create_checkbox_check.pdf"
)
with open(expected_path, "rb+") as f:
obj = PdfWrapper(template_stream).create_widget(
"checkbox",
"foo",
1,
100,
100,
button_style="check",
)
obj.fill(obj.sample_data)

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

expected = f.read()

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


def test_create_checkbox_circle(template_stream, pdf_samples, request):
expected_path = os.path.join(
pdf_samples, "widget", "create_checkbox_circle.pdf"
)
with open(expected_path, "rb+") as f:
obj = PdfWrapper(template_stream).create_widget(
"checkbox",
"foo",
1,
100,
100,
button_style="circle",
)
obj.fill(obj.sample_data)

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

expected = f.read()

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


def test_create_checkbox_cross(template_stream, pdf_samples, request):
expected_path = os.path.join(
pdf_samples, "widget", "create_checkbox_cross.pdf"
)
with open(expected_path, "rb+") as f:
obj = PdfWrapper(template_stream).create_widget(
"checkbox",
"foo",
1,
100,
100,
button_style="cross",
)
obj.fill(obj.sample_data)

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

expected = f.read()

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


def test_create_checkbox_complex_filled(template_stream, pdf_samples, request):
expected_path = os.path.join(
pdf_samples, "widget", "create_checkbox_complex_filled.pdf"
Expand Down

0 comments on commit ed7aae1

Please sign in to comment.