Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Add xmp test #1775

Merged
merged 6 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions tests/test_xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@
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_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"}


@pytest.mark.parametrize(
Expand Down