diff --git a/repo2docker/contentproviders/doi.py b/repo2docker/contentproviders/doi.py index 83ef79a7..6ec2c8e1 100644 --- a/repo2docker/contentproviders/doi.py +++ b/repo2docker/contentproviders/doi.py @@ -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 diff --git a/repo2docker/contentproviders/figshare.py b/repo2docker/contentproviders/figshare.py index 1cec5ef2..36aa8067 100644 --- a/repo2docker/contentproviders/figshare.py +++ b/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) diff --git a/tests/unit/contentproviders/test_figshare.py b/tests/unit/contentproviders/test_figshare.py index 2d15a825..0e152ecf 100644 --- a/tests/unit/contentproviders/test_figshare.py +++ b/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(): +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()