fix content_id for Figshare
MODIFY
repo2docker/contentproviders/doi.py
repo2docker/contentproviders/doi.py
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

MODIFY
repo2docker/contentproviders/figshare.py
repo2docker/contentproviders/figshare.py
@@ -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)

MODIFY
tests/unit/contentproviders/test_figshare.py
tests/unit/contentproviders/test_figshare.py
@@ -14,23 +14,20 @@ from repo2docker.contentproviders import Figshare
from repo2docker.__main__ import make_r2d
-def test_content_id():
- with patch.object(Figshare, "urlopen") as fake_urlopen:
- fake_urlopen.return_value.url = "https://figshare.com/articles/title/9782777"
- 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"
+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"),
+]
-def test_content_version():
+@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/2"
+ fake_urlopen.return_value.url = link
fig = Figshare()
- fig.detect("10.6084/m9.figshare.9782777.v2")
- assert fig.content_version == "2"
+ fig.detect("10.6084/m9.figshare.9782777")
+ assert fig.content_id == expected
test_fig = Figshare()

fix content_id for Figshare