Skip to content

PDFCLOUD-5839 Re-align tests with API#42

Merged
datalogics-kam merged 5 commits into
mainfrom
pdfcloud-5839-tests
Jun 9, 2026
Merged

PDFCLOUD-5839 Re-align tests with API#42
datalogics-kam merged 5 commits into
mainfrom
pdfcloud-5839-tests

Conversation

@datalogics-cgreen

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

Copy link
Copy Markdown
Contributor

PDFCLOUD-5839

Why this change

This branch closes two validation gaps in the SDK’s live and payload-level coverage.

First, convert_to_pdfa now accepts case-insensitive output_type strings at validation time while keeping the public type surface opinionated around the canonical PdfAType literals. That preserves IDE guidance and stricter typing for callers without forcing runtime inputs to already match the canonical case.

Second, the live signing suite was treating logo_opacity=0.0 as invalid even though zero opacity is a valid boundary value. That left the branch without a test proving the lower bound is accepted.

What changed

For PDF/A conversion, the payload validator now normalizes string output_type values case-insensitively before enforcing the existing PdfAType literal. The canonical allowed values are derived from get_args(PdfAType) so the validation logic does not maintain a second hard-coded list.

The PDF/A live suite was updated to add explicit sync and async lowercase input coverage, while preserving the canonical uppercase coverage already driven from PdfAType.

For signing, the live tests now separate the invalid-opacity coverage from the zero-opacity boundary. Negative values remain the lower-bound failure case, and new sync and async live tests assert that logo_opacity=0.0 succeeds.

Behavior changes

convert_to_pdfa now accepts inputs such as "pdf/a-2b" and normalizes them to the canonical PDF/A literal before request serialization. Invalid values still fail validation or server-side checks as before.

The sign-PDF live suite now reflects the intended boundary behavior for logo_opacity: values below 0.0 are rejected, while exactly 0.0 is treated as valid.

Validation

Validated locally with:

  • uv run pytest -n auto --maxschedchunk 2 tests/test_convert_to_pdfa.py
  • uv run ruff check tests/test_convert_to_pdfa.py
  • uv run basedpyright tests/test_convert_to_pdfa.py tests/live/test_live_convert_to_pdfa.py

Not run locally:

  • tests/live/test_live_convert_to_pdfa.py
  • tests/live/test_live_sign_pdf.py

Those live suites require pdfRest credentials and service access.

Risks and follow-ups

The main runtime change is intentionally narrow and limited to PDF/A output_type normalization. The larger risk is drift between live API behavior and the SDK’s expectations, which is why the added live coverage matters here.

This branch does not add broader unit coverage for lowercase PDF/A inputs beyond the existing focused request/validation tests, and it does not rerun the full nox matrix as part of this iteration.

@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for pdfrest-python ready!

Name Link
🔨 Latest commit a05964a
🔍 Latest deploy log https://app.netlify.com/projects/pdfrest-python/deploys/6a282ee1295ae60008e6e05d
😎 Deploy Preview https://deploy-preview-42--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 changed the title Pdfcloud 5839 tests PDFCLOUD-5839 Re-align tests with API Jun 2, 2026
@datalogics-cgreen datalogics-cgreen marked this pull request as ready for review June 2, 2026 15:17
@datalogics-kam datalogics-kam self-requested a review June 2, 2026 18:29
@datalogics-kam datalogics-kam self-assigned this Jun 2, 2026
@datalogics-kam datalogics-kam reopened this Jun 2, 2026
@datalogics-kam

Copy link
Copy Markdown
Contributor

Had to close and open to get the tests to run, go figure.

@datalogics-kam datalogics-kam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the PDF/A support.

  • Don't change the client interface to be open ended for PdfAType. It should still strictly declare canonical types. Type hinting is a hint, so the user can still pass a lower case str, and the low level validation will fix it.
  • I agree on the less strict validation before going to pdfRest, just avoid duplicating lists of values by using get_args.

Comment thread src/pdfrest/client.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread tests/test_convert_to_pdfa.py Outdated
Comment thread tests/test_convert_to_pdfa.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated

@datalogics-kam datalogics-kam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review findings from Codex PR Review Auditor. I did not rerun live tests because the previously attached live server was incorrect; the comments below are based on the diff, policy files, and focused mocked/unit coverage.

Comment thread src/pdfrest/models/_internal.py
Comment thread tests/live/test_live_sign_pdf.py Outdated

@datalogics-kam datalogics-kam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PDF/A work looks a lot better, but I ran the PR Review Auditor skill and it found a few things; please address those.

- Add sync and async MockTransport coverage for lowercase PDF/A
  output_type inputs in convert_to_pdfa.
- Assert the outbound /pdfa request body normalizes those values to
  canonical PDF/A-2b.
- Preserve the intent of the live tests with local unit coverage so
  request serialization regressions fail before live runs.

Assisted-by: Codex
- Relax logo_opacity validation from gt=0 to ge=0 so callers can pass
  0.0 through the public signature_configuration path.
- Update the public signature-configuration type docs to reflect the
  supported [0, 1] opacity range.
- Add sync and async unit coverage for request serialization and
  update payload bounds tests and live zero-opacity cases to exercise
  the public argument path instead of extra_body.
- Keep zero-opacity support aligned across validation, documentation,
  unit tests, and live tests.

Assisted-by: Codex

@datalogics-kam datalogics-kam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Could you add a version bump to 1.0.4 to this please?

@datalogics-kam datalogics-kam merged commit f139a7f into main Jun 9, 2026
20 checks passed
@datalogics-kam datalogics-kam deleted the pdfcloud-5839-tests branch June 9, 2026 22:36
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