Skip to content

Commit d71ec95

Browse files
models/tests: Enforce logo_opacity > 0 and update validation tests
- Updated `_PdfSignatureConfigurationModel` to set `logo_opacity` lower bound as strictly greater than 0 (`gt=0`) instead of greater than or equal to 0 (`ge=0`). - Modified `test_sign_pdf.py` to reflect the updated constraint: - Adjusted parametrized tests to replace 0.0 with 0.01 for minimum valid opacity. - Added test case for 0.0 as an invalid opacity value. - Updated validation error match regex to account for the new rule. Assisted-by: Codex
1 parent 41199cd commit d71ec95

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/pdfrest/models/_internal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ class _PdfSignatureDisplayModel(BaseModel):
985985
class _PdfSignatureConfigurationModel(BaseModel):
986986
type: Literal["new", "existing"]
987987
name: str | None = None
988-
logo_opacity: Annotated[float | None, Field(ge=0, le=1, default=None)] = None
988+
logo_opacity: Annotated[float | None, Field(gt=0, le=1, default=None)] = None
989989
location: _PdfSignatureLocationModel | None = None
990990
display: _PdfSignatureDisplayModel | None = None
991991

tests/test_sign_pdf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def test_sign_payload_accepts_logo_tuple_sequence() -> None:
707707
@pytest.mark.parametrize(
708708
"logo_opacity",
709709
[
710-
pytest.param(0.0, id="min"),
710+
pytest.param(0.01, id="min"),
711711
pytest.param(1.0, id="max"),
712712
],
713713
)
@@ -735,6 +735,7 @@ def test_sign_payload_accepts_logo_opacity_bounds(logo_opacity: float) -> None:
735735
@pytest.mark.parametrize(
736736
"invalid_logo_opacity",
737737
[
738+
pytest.param(0.0, id="zero"),
738739
pytest.param(-0.01, id="below-min"),
739740
pytest.param(1.01, id="above-max"),
740741
],
@@ -748,7 +749,7 @@ def test_sign_payload_rejects_logo_opacity_out_of_bounds(
748749

749750
with pytest.raises(
750751
ValidationError,
751-
match=r"greater than or equal to 0|less than or equal to 1",
752+
match=r"greater than 0|less than or equal to 1",
752753
):
753754
PdfSignPayload.model_validate(
754755
{

0 commit comments

Comments
 (0)