PDFCLOUD-5839 Re-align tests with API#41
Closed
datalogics-cgreen wants to merge 2 commits into
Closed
Conversation
Assisted-by: Codex
Assisted-by: Codex
✅ Deploy Preview for pdfrest-python ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
In this repo, due to the way the environments and permissions work, for this project, PRs have to be made from the main repo, not forks. Please push to https://github.com/pdfrest/pdfrest-python and reopen. Thanks! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this change
This branch tightens two places where the SDK’s behavior and its test coverage were out of sync with the live service. First,
convert_to_pdfawas stricter than it needed to be about PDF/A conformance names, rejecting lowercase inputs even though callers can reasonably treat these values as case-insensitive labels. That creates avoidable friction for integrators and pushes a formatting concern onto users instead of the client.Second, the live
sign_pdfcoverage aroundlogo_opacitywas masking the actual server behavior. The negative tests were entangled with unrelated validation on the signature payload, which made it harder to tell whether failures were really about opacity bounds. Tightening that coverage matters because these tests are supposed to document and lock in the wire-level contract, not accidentally pass for the wrong reason.What changed
The PDF/A change is intentionally small in surface area: the public client now accepts a broader caller-facing input type for
output_type, normalizes it before validation, and still serializes the canonical PDF/A value on the wire. This keeps the payload model authoritative while making the API more forgiving at the edge. The tradeoff is that the SDK now treats casing as non-semantic for this specific field, which is appropriate because the live API already behaves that way.The signing work does not change the signing implementation itself. Instead, it makes the live tests more precise by isolating
logo_opacityfrom unrelated required-field failures and by adding explicit success coverage for0.0. That shifts the tests from “some invalid request failed” to “the documented boundary is actually what the server enforces,” which is more useful for reviewers and future regressions.Behavior changes
At runtime,
convert_to_pdfanow accepts lowercase or otherwise case-varied PDF/A output names such aspdf/a-2band normalizes them to the canonical supported values. Invalid conformance targets are still rejected; this is a compatibility expansion, not a relaxation of the allowed set.There is no intended runtime behavior change for
sign_pdf. The change is in what the test suite now proves:logo_opacity=0.0is treated as a valid lower boundary, while values below0.0and above1.0remain invalid. That clarifies an edge case that was previously covered ambiguously.Breaking changes: none.
Validation
Validation in this branch is primarily test-driven. The branch adds and updates:
convert_to_pdfausing lowercaseoutput_typevalues in both sync and async clientssign_pdfacceptslogo_opacity=0.0sign_pdfthat now isolate true opacity-bound failuresLimitations: this branch is narrowly focused on these contract edges. It does not broaden PDF/A acceptance beyond case normalization, and it does not change signing payload validation outside the test assertions described above.
Risks and follow-ups
Risk is low because the only runtime change is an input-normalization path before existing validation. The main thing to watch is whether downstream code or docs assume PDF/A conformance names must be passed in canonical uppercase form; if so, that guidance is now stricter than the SDK behavior.
There is no migration work required for existing callers. This is backward-compatible and only makes previously failing valid inputs succeed.
A reasonable follow-up is to review other enum-like request fields for the same mismatch between SDK strictness and live API behavior, but only where the service clearly treats values case-insensitively.