-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from chinapandaman/PPF-387
PPF-387: implement preview method
- Loading branch information
Showing
12 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
|
||
from PyPDFForm import PyPDFForm | ||
|
||
|
||
def test_preview(template_stream, pdf_samples, request): | ||
expected_path = os.path.join(pdf_samples, "preview", "test_preview.pdf") | ||
with open(expected_path, "rb+") as f: | ||
preview = PyPDFForm(template_stream).preview | ||
|
||
request.config.results["expected_path"] = expected_path | ||
request.config.results["stream"] = preview | ||
|
||
expected = f.read() | ||
|
||
assert len(preview) == len(expected) | ||
assert preview == expected | ||
|
||
|
||
def test_preview_sejda(sejda_template, pdf_samples, request): | ||
expected_path = os.path.join(pdf_samples, "preview", "test_preview_sejda.pdf") | ||
with open(expected_path, "rb+") as f: | ||
preview = PyPDFForm(sejda_template).preview | ||
|
||
request.config.results["expected_path"] = expected_path | ||
request.config.results["stream"] = preview | ||
|
||
expected = f.read() | ||
|
||
assert len(preview) == len(expected) | ||
assert preview == expected | ||
|
||
|
||
def test_preview_paragraph_complex(sample_template_paragraph_complex, pdf_samples, request): | ||
expected_path = os.path.join(pdf_samples, "preview", "test_preview_paragraph_complex.pdf") | ||
with open(expected_path, "rb+") as f: | ||
preview = PyPDFForm(sample_template_paragraph_complex).preview | ||
|
||
request.config.results["expected_path"] = expected_path | ||
request.config.results["stream"] = preview | ||
|
||
expected = f.read() | ||
|
||
assert len(preview) == len(expected) | ||
assert preview == expected | ||
|
||
|
||
def test_preview_sejda_complex(sejda_template_complex, pdf_samples, request): | ||
expected_path = os.path.join(pdf_samples, "preview", "test_preview_sejda_complex.pdf") | ||
with open(expected_path, "rb+") as f: | ||
preview = PyPDFForm(sejda_template_complex).preview | ||
|
||
request.config.results["expected_path"] = expected_path | ||
request.config.results["stream"] = preview | ||
|
||
expected = f.read() | ||
|
||
assert len(preview) == len(expected) | ||
assert preview == expected | ||
|
||
|
||
def test_preview_comb_text_field(sample_template_with_comb_text_field, pdf_samples, request): | ||
expected_path = os.path.join(pdf_samples, "preview", "test_preview_comb_text_field.pdf") | ||
with open(expected_path, "rb+") as f: | ||
preview = PyPDFForm(sample_template_with_comb_text_field).preview | ||
|
||
request.config.results["expected_path"] = expected_path | ||
request.config.results["stream"] = preview | ||
|
||
expected = f.read() | ||
|
||
assert len(preview) == len(expected) | ||
assert preview == expected |