add support for Figshare versions > 9

pull/788/head
Daniel Nüst 2019-09-11 13:18:20 +02:00
rodzic 698b8a1d7e
commit f1ec646d2e
2 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -39,7 +39,7 @@ class Figshare(DoiProvider):
}
]
url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d)?")
url_regex = re.compile(r"(.*)/articles/([^/]+)/(\d+)(/)?(\d+)?")
def detect(self, doi, ref=None, extra_args=None):
"""Trigger this provider for things that resolve to a Figshare article"""

Wyświetl plik

@ -21,6 +21,17 @@ def test_content_id():
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"
test_fig = Figshare()
test_fig.article_id = "123456"