Skip to content

Commit

Permalink
TST: Add xmp test (#1775)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma authored Apr 9, 2023
1 parent 10cc057 commit ac0cb98
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sample-files
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

0 comments on commit ac0cb98

Please sign in to comment.