Skip to content

Commit 45229ad

Browse files
authored
Merge pull request #1001 from manics/fix_figshare_test
2 parents a0606f2 + ee7f779 commit 45229ad

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

repo2docker/contentproviders/figshare.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def __init__(self):
4040
}
4141
]
4242

43-
url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d+)?")
43+
# We may need to add other item types in future, see
44+
# https://github.com/jupyterhub/repo2docker/pull/1001#issuecomment-760107436
45+
# for a list
46+
url_regex = re.compile(r"(.*)/articles/(code/|dataset/)?([^/]+)/(\d+)(/)?(\d+)?")
4447

4548
def detect(self, doi, ref=None, extra_args=None):
4649
"""Trigger this provider for things that resolve to a Figshare article"""
@@ -54,8 +57,8 @@ def detect(self, doi, ref=None, extra_args=None):
5457
if any([url.startswith(s) for s in host["hostname"]]):
5558
match = self.url_regex.match(url)
5659
if match:
57-
self.article_id = match.groups()[2]
58-
self.article_version = match.groups()[4]
60+
self.article_id = match.groups()[3]
61+
self.article_version = match.groups()[5]
5962
if not self.article_version:
6063
self.article_version = "1"
6164
return {

tests/unit/contentproviders/test_figshare.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,28 @@ def mocked_get(req, context):
4848
"10.6084/m9.figshare.9782777.v1",
4949
{"host": test_fig.hosts[0], "article": "9782777", "version": "1"},
5050
),
51-
(
51+
pytest.param(
5252
"10.6084/m9.figshare.9782777.v2",
5353
{"host": test_fig.hosts[0], "article": "9782777", "version": "2"},
54+
# $ curl -sIL https://dx.doi.org/10.6084/m9.figshare.9782777.v2 | grep location
55+
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/2
56+
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
57+
marks=pytest.mark.xfail(reason="Problem with figshare version redirects"),
5458
),
5559
(
5660
"https://doi.org/10.6084/m9.figshare.9782777.v1",
5761
{"host": test_fig.hosts[0], "article": "9782777", "version": "1"},
62+
# $ curl -sIL https://doi.org/10.6084/m9.figshare.9782777.v1 | grep location
63+
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/1
64+
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
5865
),
59-
(
66+
pytest.param(
6067
"https://doi.org/10.6084/m9.figshare.9782777.v3",
6168
{"host": test_fig.hosts[0], "article": "9782777", "version": "3"},
69+
# $ curl -sIL https://doi.org/10.6084/m9.figshare.9782777.v3 | grep location
70+
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/3
71+
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
72+
marks=pytest.mark.xfail(reason="Problem with figshare version redirects"),
6273
),
6374
(
6475
"https://figshare.com/articles/title/97827771234",

0 commit comments

Comments
 (0)