Coverage for gws-app/gws/lib/pdf/_test/pdf_test.py: 100%
17 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
1"""Tests for the pdf module."""
3import gws
4import gws.test.util as u
5import gws.lib.pdf as p
6import gws.lib.mime
7import gws.lib.htmlx as htmlx
10def make_test_pdfs(dir: str):
11 s = '<div style="position: absolute; top: 0mm; left: 0mm;">A</div>'
12 htmlx.render_to_pdf(s, f'{dir}/_a.pdf', page_size=(30, 30, gws.Uom.mm))
14 s = '<div style="position: absolute; top: 10mm; left: 10mm;">B</div>'
15 htmlx.render_to_pdf(s, f'{dir}/_b.pdf', page_size=(30, 30, gws.Uom.mm))
17 s = '<div style="position: absolute; top: 20mm; left: 20mm;">C</div>'
18 htmlx.render_to_pdf(s, f'{dir}/_c.pdf', page_size=(30, 30, gws.Uom.mm))
20 p.concat([f'{dir}/_a.pdf', f'{dir}/_b.pdf', f'{dir}/_c.pdf'], f'{dir}/_abc.pdf')
21 p.concat([f'{dir}/_b.pdf', f'{dir}/_c.pdf', f'{dir}/_a.pdf'], f'{dir}/_bca.pdf')
23 p.overlay(f'{dir}/_abc.pdf', f'{dir}/_bca.pdf', f'{dir}/_abc_bca.pdf')
26def test_all(tmp_path):
27 make_test_pdfs(str(tmp_path))
28 # @TODO: verify content