kopia lustrzana https://github.com/jupyterhub/repo2docker
fix content_id for Figshare
rodzic
f1ec646d2e
commit
a40e1799bd
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import abc
|
||||
import json
|
||||
import shutil
|
||||
import logging
|
||||
|
@ -89,8 +88,3 @@ class DoiProvider(ContentProvider):
|
|||
shutil.rmtree(path.join(output_dir, d))
|
||||
|
||||
yield "Fetched files: {}\n".format(os.listdir(output_dir))
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def content_id(self):
|
||||
pass
|
||||
|
|
|
@ -94,9 +94,4 @@ class Figshare(DoiProvider):
|
|||
@property
|
||||
def content_id(self):
|
||||
"""The Figshare article ID"""
|
||||
return self.article_id
|
||||
|
||||
@property
|
||||
def content_version(self):
|
||||
"""The Figshare article ID"""
|
||||
return self.article_version
|
||||
return "{}.v{}".format(self.article_id, self.article_version)
|
||||
|
|
|
@ -14,23 +14,20 @@ from repo2docker.contentproviders import Figshare
|
|||
from repo2docker.__main__ import make_r2d
|
||||
|
||||
|
||||
def test_content_id():
|
||||
test_content_ids = [
|
||||
("https://figshare.com/articles/title/9782777", "9782777.v1"),
|
||||
("https://figshare.com/articles/title/9782777/2", "9782777.v2"),
|
||||
("https://figshare.com/articles/title/9782777/1234", "9782777.v1234"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("link,expected", test_content_ids)
|
||||
def test_content_id(link, expected):
|
||||
with patch.object(Figshare, "urlopen") as fake_urlopen:
|
||||
fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777"
|
||||
fake_urlopen.return_value.url = link
|
||||
fig = Figshare()
|
||||
fig.detect("10.6084/m9.figshare.9782777")
|
||||
assert fig.content_id == "9782777"
|
||||
|
||||
fig.detect("10.6084/m9.figshare.9782777.v123")
|
||||
assert fig.content_id == "9782777"
|
||||
|
||||
|
||||
def test_content_version():
|
||||
with patch.object(Figshare, "urlopen") as fake_urlopen:
|
||||
fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777/2"
|
||||
fig = Figshare()
|
||||
fig.detect("10.6084/m9.figshare.9782777.v2")
|
||||
assert fig.content_version == "2"
|
||||
assert fig.content_id == expected
|
||||
|
||||
|
||||
test_fig = Figshare()
|
||||
|
|
Ładowanie…
Reference in New Issue