update hydroshare version fetch to assume timestamp is in utc

pull/800/head
Scott Black 2019-10-01 11:16:34 -06:00
rodzic 3a936412af
commit d657453b3f
2 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -3,7 +3,7 @@ import os
import shutil
import time
import json
import datetime
from datetime import datetime, timezone, timedelta
from urllib.request import urlopen, Request, urlretrieve
from urllib.error import HTTPError
@ -37,7 +37,12 @@ class Hydroshare(DoiProvider):
date = next(
item for item in json_response["dates"] if item["type"] == "modified"
)["start_date"]
return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S").timestamp()
# Hydroshare timestamp always returns the same timezone, so strip it
date = date.split(".")[0]
parsed_date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S")
epoch = parsed_date.replace(tzinfo=timezone(timedelta(0))).timestamp()
# truncate the timestamp
return str(int(epoch))
url = self.doi2url(doi)

Wyświetl plik

@ -26,7 +26,7 @@ def test_content_id():
hydro = Hydroshare()
hydro.detect("10.4211/hs.b8f6eae9d89241cf8b5904033460af61")
assert hydro.content_id == "b8f6eae9d89241cf8b5904033460af61.v1569449357"
assert hydro.content_id == "b8f6eae9d89241cf8b5904033460af61.v1569427757"
test_hosts = [
@ -46,7 +46,7 @@ test_hosts = [
"version": "https://www.hydroshare.org/hsapi/resource/{}/scimeta/elements",
},
"resource": "b8f6eae9d89241cf8b5904033460af61",
"version": "1569449357",
"version": "1569427757",
},
)
]