Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions repo2docker/contentproviders/dataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def detect(self, doi, ref=None, extra_args=None):
parsed_url._replace(path="/api/search", query=search_query)
)
self.log.debug("Querying Dataverse: " + search_url)
data = self.urlopen(search_url).json()
data = self.urlopen(search_url).json()["data"]
if data["count_in_response"] != 1:
self.log.debug(
"Dataverse search query failed!\n - doi: {}\n - url: {}\n - resp: {}\n".format(
Expand Down Expand Up @@ -103,7 +103,7 @@ def fetch(self, spec, output_dir, yield_output=False):
)

resp = self.urlopen(url, headers={"accept": "application/json"})
record = resp.json()
record = resp.json()["data"]

for fobj in deep_get(record, "latestVersion.files"):
file_url = "{}/api/access/datafile/{}".format(
Expand Down
36 changes: 20 additions & 16 deletions tests/unit/contentproviders/test_dataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def doi_resolver(req, context):
requests_mock.get(
"https://dataverse.harvard.edu/api/search?q=entityId:3323458&type=file",
json={
"count_in_response": 1,
"items": [{"dataset_persistent_id": "doi:10.7910/DVN/6ZXAGT"}],
"data": {
"count_in_response": 1,
"items": [{"dataset_persistent_id": "doi:10.7910/DVN/6ZXAGT"}],
}
},
)

Expand Down Expand Up @@ -109,20 +111,22 @@ def dv_files(tmpdir):

def test_dataverse_fetch(dv_files, requests_mock):
mock_response = {
"latestVersion": {
"files": [
{"dataFile": {"id": 1}, "label": "some-file.txt"},
{
"dataFile": {"id": 2},
"label": "some-other-file.txt",
"directoryLabel": "directory",
},
{
"dataFile": {"id": 3},
"label": "the-other-file.txt",
"directoryLabel": "directory/subdirectory",
},
]
"data": {
"latestVersion": {
"files": [
{"dataFile": {"id": 1}, "label": "some-file.txt"},
{
"dataFile": {"id": 2},
"label": "some-other-file.txt",
"directoryLabel": "directory",
},
{
"dataFile": {"id": 3},
"label": "the-other-file.txt",
"directoryLabel": "directory/subdirectory",
},
]
}
}
}

Expand Down