kopia lustrzana https://github.com/jupyterhub/repo2docker
Merge pull request #1001 from manics/fix_figshare_test
commit
45229ad613
|
@ -40,7 +40,10 @@ class Figshare(DoiProvider):
|
|||
}
|
||||
]
|
||||
|
||||
url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d+)?")
|
||||
# We may need to add other item types in future, see
|
||||
# https://github.com/jupyterhub/repo2docker/pull/1001#issuecomment-760107436
|
||||
# for a list
|
||||
url_regex = re.compile(r"(.*)/articles/(code/|dataset/)?([^/]+)/(\d+)(/)?(\d+)?")
|
||||
|
||||
def detect(self, doi, ref=None, extra_args=None):
|
||||
"""Trigger this provider for things that resolve to a Figshare article"""
|
||||
|
@ -54,8 +57,8 @@ class Figshare(DoiProvider):
|
|||
if any([url.startswith(s) for s in host["hostname"]]):
|
||||
match = self.url_regex.match(url)
|
||||
if match:
|
||||
self.article_id = match.groups()[2]
|
||||
self.article_version = match.groups()[4]
|
||||
self.article_id = match.groups()[3]
|
||||
self.article_version = match.groups()[5]
|
||||
if not self.article_version:
|
||||
self.article_version = "1"
|
||||
return {
|
||||
|
|
|
@ -48,17 +48,28 @@ test_dois_links = [
|
|||
"10.6084/m9.figshare.9782777.v1",
|
||||
{"host": test_fig.hosts[0], "article": "9782777", "version": "1"},
|
||||
),
|
||||
(
|
||||
pytest.param(
|
||||
"10.6084/m9.figshare.9782777.v2",
|
||||
{"host": test_fig.hosts[0], "article": "9782777", "version": "2"},
|
||||
# $ curl -sIL https://dx.doi.org/10.6084/m9.figshare.9782777.v2 | grep location
|
||||
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/2
|
||||
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
|
||||
marks=pytest.mark.xfail(reason="Problem with figshare version redirects"),
|
||||
),
|
||||
(
|
||||
"https://doi.org/10.6084/m9.figshare.9782777.v1",
|
||||
{"host": test_fig.hosts[0], "article": "9782777", "version": "1"},
|
||||
# $ curl -sIL https://doi.org/10.6084/m9.figshare.9782777.v1 | grep location
|
||||
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/1
|
||||
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
|
||||
),
|
||||
(
|
||||
pytest.param(
|
||||
"https://doi.org/10.6084/m9.figshare.9782777.v3",
|
||||
{"host": test_fig.hosts[0], "article": "9782777", "version": "3"},
|
||||
# $ curl -sIL https://doi.org/10.6084/m9.figshare.9782777.v3 | grep location
|
||||
# location: https://figshare.com/articles/Binder-ready_openSenseMap_Analysis/9782777/3
|
||||
# location: https://figshare.com/articles/code/Binder-ready_openSenseMap_Analysis/9782777
|
||||
marks=pytest.mark.xfail(reason="Problem with figshare version redirects"),
|
||||
),
|
||||
(
|
||||
"https://figshare.com/articles/title/97827771234",
|
||||
|
|
Ładowanie…
Reference in New Issue