Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Fix bug where open access titles in ODL feeds would fail to import (P…
Browse files Browse the repository at this point in the history
…P-847) (#147)

* Fix bug where open access titles in ODL feeds would fail to import.

* Lint files

* Fix test descriptions.
  • Loading branch information
jonathangreen authored Jan 17, 2024
1 parent c6cd0b2 commit 42af1cb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
build-backend = "poetry.masonry.api"
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]

[tool.isort]
Expand Down
2 changes: 1 addition & 1 deletion src/webpub_manifest_parser/odl/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def visit(self, node):
self._logger.debug(f"Started processing {encode(node)}")

if (not node.licenses or len(node.licenses) == 0) and (
(not node.licenses or len(node.links) == 0)
(not node.links or len(node.links) == 0)
or not node.links.get_by_rel(OPDS2LinkRelationsRegistry.OPEN_ACCESS.key)
):
with self._record_errors():
Expand Down
32 changes: 32 additions & 0 deletions tests/webpub_manifest_parser/odl/test_semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,38 @@ class ODLSemanticAnalyzerTest(AnalyzerTest):
)
],
),
(
"when_publication_does_not_contain_licenses_and_has_a_oa_link",
ODLFeed(
metadata=OPDS2FeedMetadata(title="test"),
links=LinkList(
[
Link(
href="http://example.com",
rels=[LinkRelationsRegistry.SELF.key],
)
]
),
publications=CollectionList(
[
ODLPublication(
metadata=PresentationMetadata(title="Publication 1"),
links=LinkList(
[
Link(
href="http://example.com",
rels=[
OPDS2LinkRelationsRegistry.OPEN_ACCESS.key
],
)
]
),
)
]
),
),
[],
),
(
"when_license_does_not_contain_self_link_and_borrow_link",
ODLFeed(
Expand Down

0 comments on commit 42af1cb

Please sign in to comment.