Skip to content

Commit a40e179

Browse files
committed
fix content_id for Figshare
1 parent f1ec646 commit a40e179

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

repo2docker/contentproviders/doi.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import abc
32
import json
43
import shutil
54
import logging
@@ -89,8 +88,3 @@ def fetch_file(self, file_ref, host, output_dir, unzip=False):
8988
shutil.rmtree(path.join(output_dir, d))
9089

9190
yield "Fetched files: {}\n".format(os.listdir(output_dir))
92-
93-
@property
94-
@abc.abstractmethod
95-
def content_id(self):
96-
pass

repo2docker/contentproviders/figshare.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,4 @@ def fetch(self, spec, output_dir, yield_output=False):
9494
@property
9595
def content_id(self):
9696
"""The Figshare article ID"""
97-
return self.article_id
98-
99-
@property
100-
def content_version(self):
101-
"""The Figshare article ID"""
102-
return self.article_version
97+
return "{}.v{}".format(self.article_id, self.article_version)

tests/unit/contentproviders/test_figshare.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,20 @@
1414
from repo2docker.__main__ import make_r2d
1515

1616

17-
def test_content_id():
18-
with patch.object(Figshare, "urlopen") as fake_urlopen:
19-
fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777"
20-
fig = Figshare()
21-
fig.detect("10.6084/m9.figshare.9782777")
22-
assert fig.content_id == "9782777"
23-
24-
fig.detect("10.6084/m9.figshare.9782777.v123")
25-
assert fig.content_id == "9782777"
17+
test_content_ids = [
18+
("https://figshare.com/articles/title/9782777", "9782777.v1"),
19+
("https://figshare.com/articles/title/9782777/2", "9782777.v2"),
20+
("https://figshare.com/articles/title/9782777/1234", "9782777.v1234"),
21+
]
2622

2723

28-
def test_content_version():
24+
@pytest.mark.parametrize("link,expected", test_content_ids)
25+
def test_content_id(link, expected):
2926
with patch.object(Figshare, "urlopen") as fake_urlopen:
30-
fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777/2"
27+
fake_urlopen.return_value.url = link
3128
fig = Figshare()
32-
fig.detect("10.6084/m9.figshare.9782777.v2")
33-
assert fig.content_version == "2"
29+
fig.detect("10.6084/m9.figshare.9782777")
30+
assert fig.content_id == expected
3431

3532

3633
test_fig = Figshare()

0 commit comments

Comments
 (0)