diff --git a/README.md b/README.md index 9c6045c..0fedd05 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ from lpdf import L, NoAttr, DocumentAttr, LayoutAttr, ColumnAttr, RowAttr, TextA engine = L.engine() -doc = L.document(DocumentAttr(size='letter'), [ +doc = L.document(DocumentAttr(size='Letter'), [ L.section(NoAttr, [ L.layout(LayoutAttr(margin='48pt'), [ L.column(ColumnAttr(gap='24pt'), [ diff --git a/src/lpdf/constants.py b/src/lpdf/constants.py index 3bd01e0..56ceea5 100644 --- a/src/lpdf/constants.py +++ b/src/lpdf/constants.py @@ -49,18 +49,18 @@ class PageSize(StrEnum): """The named values of the `size` attribute of a document or a section. A width and a height, such as 100pt 200pt, is a string.""" - A0 = "a0" - A1 = "a1" - A2 = "a2" - A3 = "a3" - A4 = "a4" - A5 = "a5" - A6 = "a6" - B4 = "b4" - B5 = "b5" - LETTER = "letter" - LEGAL = "legal" - TABLOID = "tabloid" + A0 = "A0" + A1 = "A1" + A2 = "A2" + A3 = "A3" + A4 = "A4" + A5 = "A5" + A6 = "A6" + B4 = "B4" + B5 = "B5" + LETTER = "Letter" + LEGAL = "Legal" + TABLOID = "Tabloid" class Orientation(StrEnum): diff --git a/tests/test_cross_industry_invoice.py b/tests/test_cross_industry_invoice.py index f8030f8..072ad8d 100644 --- a/tests/test_cross_industry_invoice.py +++ b/tests/test_cross_industry_invoice.py @@ -30,7 +30,7 @@ '') RECHNUNG_TEMPLATE = ( '' - '
' + '
' '0000' '
' ) @@ -101,7 +101,7 @@ def document_in_code(invoice_data: dict): L.text(muted, ["VAT in"]), L.text(muted, [totals["taxCurrency"]]), L.text(muted, [totals["vatInTaxCurrency"]]), ])] if "vatInTaxCurrency" in totals else [] return L.document(DocumentAttr( - size="a4", font="body", + size="A4", font="body", assets=DocumentAssets(fonts=[FontAttr(name="body", src="../assets/fonts/SourceSans3-Regular.otf")]), meta=DocumentMeta(title="Invoice", author="Northwind Paper SAS", lang="en"), ), [ diff --git a/tests/test_engine.py b/tests/test_engine.py index 749102a..c04db20 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -256,7 +256,7 @@ def test_render_xml_auto_loads_image_src(self, invoke, tmp_path): invoke.return_value = _engine_response() img_file = tmp_path / "logo.png" img_file.write_bytes(b"\x89PNG") - xml = f'' + xml = f'' engine = PdfEngine().set_license_key("key") engine.render(xml) payload = _extract_payload(invoke) diff --git a/tests/test_kit.py b/tests/test_kit.py index c30324e..d3459eb 100644 --- a/tests/test_kit.py +++ b/tests/test_kit.py @@ -67,10 +67,10 @@ def test_divider(): def test_section(): layout = L.layout(NoAttr, [L.text(NoAttr, ["Hello"])]) - section = L.section(SectionAttr(size="a4", background="#ffffff"), [layout]) + section = L.section(SectionAttr(size="A4", background="#ffffff"), [layout]) d = section.to_dict() assert d["type"] == "section" - assert d["attrs"] == {"size": "a4", "background": "#ffffff"} + assert d["attrs"] == {"size": "A4", "background": "#ffffff"} assert len(d["nodes"]) == 1 @@ -113,13 +113,13 @@ def test_document_includes_version(): def test_document_with_meta_and_tokens(): doc = L.document( DocumentAttr( - size="a4", + size="A4", meta=DocumentMeta(title="Test", author="Me"), tokens=DocumentTokens(colors={"primary": "#000"}), ), ) d = doc.to_dict() - assert d["attrs"]["size"] == "a4" + assert d["attrs"]["size"] == "A4" assert d["attrs"]["meta"] == {"title": "Test", "author": "Me"} assert d["attrs"]["tokens"] == {"colors": {"primary": "#000"}} diff --git a/tests/test_schema.py b/tests/test_schema.py index 452ad29..bbcbdd3 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -118,8 +118,8 @@ def test_a_required_attribute_cannot_be_left_out(): @pytest.mark.parametrize("build", [ pytest.param(lambda: ImgAttr("logo", "40pt"), id="ImgAttr"), # type: ignore[call-arg] pytest.param(lambda: TextAttr("12pt"), id="TextAttr"), # type: ignore[call-arg] - pytest.param(lambda: SectionAttr("a4"), id="SectionAttr"), # type: ignore[call-arg] - pytest.param(lambda: DocumentAttr("letter"), id="DocumentAttr"), # type: ignore[call-arg] + pytest.param(lambda: SectionAttr("A4"), id="SectionAttr"), # type: ignore[call-arg] + pytest.param(lambda: DocumentAttr("Letter"), id="DocumentAttr"), # type: ignore[call-arg] pytest.param(lambda: DocumentMeta("Report"), id="DocumentMeta"), # type: ignore[call-arg] pytest.param(lambda: DocumentOutput("aes-256"), id="DocumentOutput"), # type: ignore[call-arg] pytest.param(lambda: DocumentTokens({"primary": "#336699"}), id="DocumentTokens"), # type: ignore[call-arg] @@ -225,7 +225,7 @@ def test_a_transform_is_a_string_a_layer_accepts(): # ── Rendering ────────────────────────────────────────────────────────────────── def _built_document(): - return L.document(DocumentAttr(size="a4"), [ + return L.document(DocumentAttr(size="A4"), [ L.section(NoAttr, [ L.layout(NoAttr, [ L.column(ColumnAttr(gap="12pt"), [ @@ -368,7 +368,7 @@ def build(columns=None): def test_a_bulk_table_renders_from_data_as_the_table_without_bulk_and_one_built_with_l_which_has_no_data_is_rejected(): def xml(bulk): return ( - '
' + '
' f'' '
DateAmount
--
' 'Page {page} of {pages}
' @@ -902,7 +902,7 @@ def test_the_constants_of_the_closed_enumerations_are_the_words_the_schema_reads assert [ PageSize.A0, PageSize.A1, PageSize.A2, PageSize.A3, PageSize.A4, PageSize.A5, PageSize.A6, PageSize.B4, PageSize.B5, PageSize.LETTER, PageSize.LEGAL, PageSize.TABLOID, - ] == ["a0", "a1", "a2", "a3", "a4", "a5", "a6", "b4", "b5", "letter", "legal", "tabloid"] + ] == ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "B4", "B5", "Letter", "Legal", "Tabloid"] assert [TextAlign.LEFT, TextAlign.CENTER, TextAlign.RIGHT, TextAlign.JUSTIFY] == ["left", "center", "right", "justify"] assert [Paginate.NO, Paginate.BREAK_BEFORE, Paginate.BREAK_AFTER, Paginate.KEEP_NEXT] == ["no", "break-before", "break-after", "keep-next"] assert Anchor.TOP_LEFT == "top-left" @@ -923,7 +923,7 @@ def test_a_document_built_with_the_constants_renders_as_the_xml_with_their_words L.barcode(BarcodeAttr(type=BarcodeType.QR, data="x", ec=QrEcLevel.H, height="40pt")), ])]), ]) - xml = '
x
' + xml = '
x
' assert _render(xml) == _render(built)