Skip to content

Commit

Permalink
Merge branch 'main' into feature/odl-dont-show-expired-items
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Aug 23, 2021
2 parents f778dc8 + c0d21fd commit 63b3926
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion api/onix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Representation,
Subject,
LicensePool, EditionConstants)
from core.util.datetime_helpers import strptime_utc
from core.util.datetime_helpers import to_utc
from core.util.xmlparser import XMLParser


Expand Down Expand Up @@ -224,6 +224,12 @@ def parse(cls, file, data_source_name, default_medium=None):
issued = None
if publishing_date:
issued = dateutil.parser.isoparse(publishing_date)
if issued.tzinfo is None:
cls._logger.warning(
"Publishing date {} does not contain timezone information. Assuming UTC."
.format(publishing_date)
)
issued = to_utc(issued)

identifier_tags = parser._xpath(record, 'productidentifier')
identifiers = []
Expand Down
2 changes: 1 addition & 1 deletion scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ def _locate_file(cls, base_filename, directory, extensions,
ext.lower()
)
content = None
with open_f(path) as fh:
with open_f(path, "rb") as fh:
content = fh.read()
return filename, media_type, content

Expand Down
2 changes: 1 addition & 1 deletion tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ def mock_exists(path):
return path in mock_filesystem

@contextlib.contextmanager
def mock_open(path):
def mock_open(path, mode="r"):
yield StringIO(mock_filesystem[path])
mock_filesystem_operations = mock_exists, mock_open

Expand Down

0 comments on commit 63b3926

Please sign in to comment.