-
Notifications
You must be signed in to change notification settings - Fork 17
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
Lower minimum poppler-cpp version to 0.26.0 #13
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e474a31
Lower minimum poppler-cpp version to 0.26.0
sandeepmistry d02439a
Update test_document.py for 0.26.0 compatibility
sandeepmistry 273daf6
Add version annotations in document.py
sandeepmistry b68de38
Update minimum poppler version in docs
sandeepmistry aeaa04a
Add poppler-0.26.0 to test matrix
sandeepmistry bdef114
Update test_page.py for poppler 0.26.0 compatibility
sandeepmistry d478aed
Use info_keys to get author, creation date, creator, keywords, mod da…
sandeepmistry ac48ba2
Only install libpoppler-cpp-dev on ubuntu poppler-version
sandeepmistry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,28 +30,33 @@ def locked_document(data_path): | |
return document.load_from_file(data_path / "document.pdf") | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_load_from_data(data_path): | ||
file_data = (data_path / "document.pdf").read_bytes() | ||
pdf_document = document.load_from_data(file_data, "owner", "user") | ||
assert pdf_document.author == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_load_with_path(data_path): | ||
pdf_document = document.load(data_path / "document.pdf", "owner", "user") | ||
assert pdf_document.author == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_load_with_filename(data_path): | ||
pdf_document = document.load(str(data_path / "document.pdf"), "owner", "user") | ||
assert pdf_document.author == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_load_with_bytes(data_path): | ||
data = (data_path / "document.pdf").read_bytes() | ||
pdf_document = document.load(data, "owner", "user") | ||
assert pdf_document.author == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_load_with_file(data_path): | ||
with (data_path / "document.pdf").open("rb") as f: | ||
pdf_document = document.load(f, "owner", "user") | ||
|
@@ -69,6 +74,7 @@ def test_load_with_invalid_type(): | |
document.load(42) | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_save(pdf_document, tmp_path): | ||
copy_document = tmp_path / "copy.pdf" | ||
pdf_document.author = "Valérie Tremblay" | ||
|
@@ -78,6 +84,7 @@ def test_save(pdf_document, tmp_path): | |
assert pdf_copy.author == "Valérie Tremblay" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_save_a_copy(pdf_document, tmp_path): | ||
copy_document = tmp_path / "copy.pdf" | ||
pdf_document.author = "Valérie Tremblay" | ||
|
@@ -95,24 +102,29 @@ def test_embedded_file(pdf_document): | |
assert pdf_document.embedded_files() == [] | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_author(pdf_document): | ||
assert pdf_document.author == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_creation_date(pdf_document): | ||
assert pdf_document.creation_date.astimezone(timezone.utc) == datetime( | ||
2020, 3, 26, 1, 19, 50, tzinfo=timezone.utc | ||
) | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_creator(pdf_document): | ||
assert pdf_document.creator == "Writer" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_keywords(pdf_document): | ||
assert pdf_document.keywords == "" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_modification_date(pdf_document): | ||
assert pdf_document.modification_date is None | ||
|
||
|
@@ -128,14 +140,17 @@ def test_get_pdf_version(pdf_document): | |
assert version == (1, 5) | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_producer(pdf_document): | ||
assert pdf_document.producer == "LibreOffice 6.4" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_subject(pdf_document): | ||
assert pdf_document.subject == "" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_get_title(pdf_document): | ||
assert pdf_document.title == "" | ||
|
||
|
@@ -158,14 +173,22 @@ def test_has_permission(pdf_document): | |
|
||
def test_info_date(pdf_document): | ||
date = pdf_document.info_date("CreationDate") | ||
assert date.astimezone(timezone.utc) == datetime( | ||
2020, 3, 26, 1, 19, 50, tzinfo=timezone.utc | ||
) | ||
if version() < (0, 46, 0): | ||
assert date.astimezone(timezone.utc) == datetime( | ||
2020, 3, 25, 21, 19, 50, tzinfo=timezone.utc | ||
) | ||
else: | ||
assert date.astimezone(timezone.utc) == datetime( | ||
2020, 3, 26, 1, 19, 50, tzinfo=timezone.utc | ||
) | ||
|
||
|
||
def test_info_key(pdf_document): | ||
info = pdf_document.info_key("Author") | ||
assert info == "Charles Brunet" | ||
if version() < (0, 46, 0): | ||
assert info == "Charles" | ||
Comment on lines
+206
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How to you explain this? Do you think it is related to
in poppler 0.46? |
||
else: | ||
assert info == "Charles Brunet" | ||
|
||
|
||
def test_info_keys(pdf_document): | ||
|
@@ -190,65 +213,76 @@ def test_metadata(pdf_document): | |
assert meta == "" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_author(pdf_document): | ||
author = "Valérie Tremblay" | ||
pdf_document.author = author | ||
assert pdf_document.author == author | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_creation_date(pdf_document): | ||
d = datetime(1980, 7, 19, 10, 30, 50) | ||
pdf_document.creation_date = d | ||
assert pdf_document.creation_date == d | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_empty_creation_date(pdf_document): | ||
pdf_document.creation_date = None | ||
assert "CreationDate" not in pdf_document.info_keys() | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_creator(pdf_document): | ||
creator = "Me" | ||
pdf_document.creator = creator | ||
assert pdf_document.creator == creator | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_keywords(pdf_document): | ||
keywords = "one, two, three" | ||
pdf_document.keywords = keywords | ||
assert pdf_document.keywords == keywords | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_modification_date(pdf_document): | ||
d = datetime(1980, 7, 19, 10, 30, 50) | ||
pdf_document.modification_date = d | ||
assert pdf_document.modification_date == d | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_producer(pdf_document): | ||
producer = "Me" | ||
pdf_document.producer = producer | ||
assert pdf_document.producer == producer | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_subject(pdf_document): | ||
subject = "Me" | ||
pdf_document.subject = subject | ||
assert pdf_document.subject == subject | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_title(pdf_document): | ||
title = "The document title" | ||
pdf_document.title = title | ||
assert pdf_document.title == title | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_info_date(pdf_document): | ||
d = datetime(1980, 7, 19, 10, 30, 50) | ||
assert pdf_document.set_info_date("CreationDate", d) is True | ||
assert pdf_document.creation_date == d | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_set_info_key(pdf_document): | ||
author = "Valérie Tremblay" | ||
assert pdf_document.set_info_key("Author", author) is True | ||
|
@@ -257,9 +291,13 @@ def test_set_info_key(pdf_document): | |
|
||
def test_infos(pdf_document): | ||
infos = pdf_document.infos() | ||
assert infos["Author"] == "Charles Brunet" | ||
if version() < (0, 46, 0): | ||
assert infos['Author'] == 'Charles' | ||
else: | ||
assert infos["Author"] == "Charles Brunet" | ||
|
||
|
||
@pytest.mark.skipif(version() < (0, 46, 0), reason="Requires at least Poppler 0.46.0") | ||
def test_remove_info(pdf_document): | ||
pdf_document.remove_info() | ||
assert not pdf_document.infos() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange... Do you think this is related to:
in version 0.45?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are-you sure the wrong date is related with the poppler version? On my side, the date is the same with older poppler version.... Are you sure you computer has the right timezone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a closer look, I'm using inside an AWS SageMaker notebook, so it might not be set. However, maybe there is somewhere else the timezone is being used incorrectly.