Skip to content

PDFCLOUD-5839 Re-align tests with API#41

Closed
datalogics-cgreen wants to merge 2 commits into
pdfrest:mainfrom
datalogics-cgreen:pdfcloud-5839-tests
Closed

PDFCLOUD-5839 Re-align tests with API#41
datalogics-cgreen wants to merge 2 commits into
pdfrest:mainfrom
datalogics-cgreen:pdfcloud-5839-tests

Conversation

@datalogics-cgreen
Copy link
Copy Markdown
Contributor

@datalogics-cgreen datalogics-cgreen commented Jun 1, 2026

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_pdfa was 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_pdf coverage around logo_opacity was 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_opacity from unrelated required-field failures and by adding explicit success coverage for 0.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_pdfa now accepts lowercase or otherwise case-varied PDF/A output names such as pdf/a-2b and 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.0 is treated as a valid lower boundary, while values below 0.0 and above 1.0 remain 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:

  • unit coverage for convert_to_pdfa using lowercase output_type values in both sync and async clients
  • live coverage proving lowercase PDF/A values succeed against the service
  • live coverage proving sign_pdf accepts logo_opacity=0.0
  • corrected live negative cases for sign_pdf that now isolate true opacity-bound failures

Limitations: 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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 1, 2026

Deploy Preview for pdfrest-python ready!

Name Link
🔨 Latest commit a3a16ca
🔍 Latest deploy log https://app.netlify.com/projects/pdfrest-python/deploys/6a1dfdd040a4be0008a20e80
😎 Deploy Preview https://deploy-preview-41--pdfrest-python.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@datalogics-cgreen datalogics-cgreen marked this pull request as ready for review June 2, 2026 14:22
@datalogics-kam datalogics-kam self-requested a review June 2, 2026 14:58
@datalogics-kam datalogics-kam self-assigned this Jun 2, 2026
@datalogics-kam
Copy link
Copy Markdown
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants