Skip to content

Commit

Permalink
Updated test provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
MillenniumFalconMechanic committed Dec 20, 2023
1 parent a7b36b7 commit 4e2e9a0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/common/providers/crossref_provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import html
import logging
from datetime import datetime
from urllib.parse import urlparse
Expand Down Expand Up @@ -101,14 +102,16 @@ def fetch_metadata(self, doi: str) -> dict:
# Journal
try:
if "short-container-title" in message and message["short-container-title"]:
journal = message["short-container-title"][0]
raw_journal = message["short-container-title"][0]

Check warning on line 105 in backend/common/providers/crossref_provider.py

View check run for this annotation

Codecov / codecov/patch

backend/common/providers/crossref_provider.py#L105

Added line #L105 was not covered by tests
elif "container-title" in message and message["container-title"]:
journal = message["container-title"][0]
raw_journal = message["container-title"][0]
elif "institution" in message:
journal = message["institution"][0]["name"]
raw_journal = message["institution"][0]["name"]

Check warning on line 109 in backend/common/providers/crossref_provider.py

View check run for this annotation

Codecov / codecov/patch

backend/common/providers/crossref_provider.py#L109

Added line #L109 was not covered by tests
except Exception:
raise CrossrefParseException("Journal node missing") from None

journal = html.unescape(raw_journal)

# Authors
# Note: make sure that the order is preserved, as it is a relevant information
authors = message["author"]
Expand Down Expand Up @@ -138,7 +141,6 @@ def fetch_metadata(self, doi: str) -> dict:
raise CrossrefParseException("Cannot parse metadata from Crossref") from e

def fetch_preprint_published_doi(self, doi):

res = self._fetch_crossref_payload(doi)
message = res.json()["message"]
is_preprint = message.get("subtype") == "preprint"
Expand Down

0 comments on commit 4e2e9a0

Please sign in to comment.