From 0ca54d3e2a41cb91afc6b0f98d8a3293792e14c9 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 20:22:40 +0200 Subject: [PATCH 1/6] TST: Add xmp test --- sample-files | 2 +- tests/test_utils.py | 4 ++-- tests/test_xmp.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sample-files b/sample-files index 65e2d2ca8..a1953b015 160000 --- a/sample-files +++ b/sample-files @@ -1 +1 @@ -Subproject commit 65e2d2ca8a137bfb1807b9991d5ca97f90365cc3 +Subproject commit a1953b015be1f2167a104446b73c5ca55b5ffeb6 diff --git a/tests/test_utils.py b/tests/test_utils.py index abb022db5..3ae80bddb 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -221,8 +221,8 @@ def test_read_block_backwards_exception(): def test_deprecation_bookmark(): @deprecation_bookmark(old_param="new_param") - def foo(old_param: int = 1, baz: int = 2) -> float: - return old_param * baz + def foo(old_param: int = 1, baz: int = 2) -> None: + pass with pytest.raises(DeprecationError) as exc: foo(old_param=12, new_param=13) diff --git a/tests/test_xmp.py b/tests/test_xmp.py index 50555b476..77cdea32b 100644 --- a/tests/test_xmp.py +++ b/tests/test_xmp.py @@ -15,6 +15,23 @@ TESTS_ROOT = Path(__file__).parent.resolve() PROJECT_ROOT = TESTS_ROOT.parent RESOURCE_ROOT = PROJECT_ROOT / "resources" +SAMPLE_ROOT = Path(PROJECT_ROOT) / "sample-files" + + +@pytest.mark.samples() +@pytest.mark.parametrize( + "src", + [ + (SAMPLE_ROOT / "020-xmp/output_with_metadata_pymupdf.pdf",), + ], +) +def test_read_xmp_metadata_samples(src): + reader = PdfReader(src) + xmp = reader.xmp_metadata + assert xmp + assert xmp.dc_contributor == [] + assert xmp.dc_creator == ["John Doe"] + assert xmp.dc_title == {"x-default": "Sample PDF with XMP Metadata"} @pytest.mark.parametrize( From bf8dcad582969492774fa434172096dfea10247f Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 20:26:17 +0200 Subject: [PATCH 2/6] Bump sample-files --- sample-files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-files b/sample-files index a1953b015..5f2f0ff9e 160000 --- a/sample-files +++ b/sample-files @@ -1 +1 @@ -Subproject commit a1953b015be1f2167a104446b73c5ca55b5ffeb6 +Subproject commit 5f2f0ff9e5ca14d245f1589918602be6b7ffbd45 From a36da7e2b8b32f14cbad48e678cee9d58f349484 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 20:37:49 +0200 Subject: [PATCH 3/6] fix --- tests/test_xmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_xmp.py b/tests/test_xmp.py index 77cdea32b..119645959 100644 --- a/tests/test_xmp.py +++ b/tests/test_xmp.py @@ -22,7 +22,7 @@ @pytest.mark.parametrize( "src", [ - (SAMPLE_ROOT / "020-xmp/output_with_metadata_pymupdf.pdf",), + (SAMPLE_ROOT / "020-xmp/output_with_metadata_pymupdf.pdf"), ], ) def test_read_xmp_metadata_samples(src): From 3e881d9edc521351ed57c3c7f88eef8b7395a003 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 20:54:16 +0200 Subject: [PATCH 4/6] No dc_date --- tests/test_xmp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_xmp.py b/tests/test_xmp.py index 119645959..5172a3770 100644 --- a/tests/test_xmp.py +++ b/tests/test_xmp.py @@ -31,6 +31,7 @@ def test_read_xmp_metadata_samples(src): assert xmp assert xmp.dc_contributor == [] assert xmp.dc_creator == ["John Doe"] + assert xmp.dc_date == [] assert xmp.dc_title == {"x-default": "Sample PDF with XMP Metadata"} From 4d2912ab93afbd1c436aed82bd67deb7b7a1ce02 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 20:58:43 +0200 Subject: [PATCH 5/6] Add xmp --- sample-files | 2 +- tests/test_xmp.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sample-files b/sample-files index 5f2f0ff9e..c908d1f9f 160000 --- a/sample-files +++ b/sample-files @@ -1 +1 @@ -Subproject commit 5f2f0ff9e5ca14d245f1589918602be6b7ffbd45 +Subproject commit c908d1f9fc0b52c3031a85ea8232cea4b57d5147 diff --git a/tests/test_xmp.py b/tests/test_xmp.py index 5172a3770..90b97a2d0 100644 --- a/tests/test_xmp.py +++ b/tests/test_xmp.py @@ -31,7 +31,7 @@ def test_read_xmp_metadata_samples(src): assert xmp assert xmp.dc_contributor == [] assert xmp.dc_creator == ["John Doe"] - assert xmp.dc_date == [] + assert xmp.dc_date == [datetime(1990, 4, 28, 0, 0)] assert xmp.dc_title == {"x-default": "Sample PDF with XMP Metadata"} From 3358e872d24c3a659165ebf1c02abb1b0e5ff1f5 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 9 Apr 2023 21:21:48 +0200 Subject: [PATCH 6/6] Test Attribute node --- sample-files | 2 +- tests/test_xmp.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sample-files b/sample-files index c908d1f9f..0c3b1d387 160000 --- a/sample-files +++ b/sample-files @@ -1 +1 @@ -Subproject commit c908d1f9fc0b52c3031a85ea8232cea4b57d5147 +Subproject commit 0c3b1d3879c5cd7d913b3d931fa33b37529d7346 diff --git a/tests/test_xmp.py b/tests/test_xmp.py index 90b97a2d0..cfcf02111 100644 --- a/tests/test_xmp.py +++ b/tests/test_xmp.py @@ -31,6 +31,8 @@ def test_read_xmp_metadata_samples(src): assert xmp assert xmp.dc_contributor == [] assert xmp.dc_creator == ["John Doe"] + assert xmp.dc_source == "Martin Thoma" # attribute node + assert xmp.dc_description == {"x-default": "This is a text"} assert xmp.dc_date == [datetime(1990, 4, 28, 0, 0)] assert xmp.dc_title == {"x-default": "Sample PDF with XMP Metadata"}