11import json
22import os
3+ import re
34import pytest
45
56from contextlib import contextmanager
1011from zipfile import ZipFile
1112
1213from repo2docker .contentproviders import Figshare
14+ from repo2docker .__main__ import make_r2d
1315
1416
1517def test_content_id ():
@@ -21,31 +23,49 @@ def test_content_id():
2123
2224
2325test_fig = Figshare ()
26+ test_fig .article_id = "123456"
27+ test_fig .article_version = "42"
28+
2429test_dois_links = [
25- ("10.6084/m9.figshare.9782777" , {"host" : test_fig .hosts [0 ], "article" : "9782777" }),
30+ (
31+ "10.6084/m9.figshare.9782777" ,
32+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "1" },
33+ ),
2634 (
2735 "10.6084/m9.figshare.9782777.v1" ,
28- {"host" : test_fig .hosts [0 ], "article" : "9782777" },
36+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "1" },
37+ ),
38+ (
39+ "10.6084/m9.figshare.9782777.v2" ,
40+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "2" },
2941 ),
3042 (
31- "https://doi.org/10.6084/m9.figshare.9782777" ,
32- {"host" : test_fig .hosts [0 ], "article" : "9782777" },
43+ "https://doi.org/10.6084/m9.figshare.9782777.v1" ,
44+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "1" },
45+ ),
46+ (
47+ "https://doi.org/10.6084/m9.figshare.9782777.v3" ,
48+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "3" },
3349 ),
3450 (
3551 "https://figshare.com/articles/title/97827771234" ,
36- {"host" : test_fig .hosts [0 ], "article" : "97827771234" },
52+ {"host" : test_fig .hosts [0 ], "article" : "97827771234" , "version" : "1" },
3753 ),
3854 (
3955 "https://figshare.com/articles/title/9782777/1" ,
40- {"host" : test_fig .hosts [0 ], "article" : "9782777" },
56+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "1" },
57+ ),
58+ (
59+ "https://figshare.com/articles/title/9782777/2" ,
60+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "2" },
4161 ),
4262 (
4363 "https://figshare.com/articles/title/9782777/" ,
44- {"host" : test_fig .hosts [0 ], "article" : "9782777" },
64+ {"host" : test_fig .hosts [0 ], "article" : "9782777" , "version" : "1" },
4565 ),
4666]
4767
48- test_spec = {"host" : test_fig .hosts [0 ], "article" : "1234" }
68+ test_spec = {"host" : test_fig .hosts [0 ], "article" : "1234" , "version" : "42" }
4969
5070
5171@pytest .mark .parametrize ("test_input,expected" , test_dois_links )
@@ -96,9 +116,8 @@ def mock_urlopen(self, req):
96116
97117 with patch .object (Figshare , "urlopen" , new = mock_urlopen ):
98118 with TemporaryDirectory () as d :
99- fig = Figshare ()
100119 output = []
101- for l in fig .fetch (test_spec , d ):
120+ for l in test_fig .fetch (test_spec , d ):
102121 output .append (l )
103122
104123 unpacked_files = set (os .listdir (d ))
@@ -137,10 +156,8 @@ def mock_urlopen(self, req):
137156
138157 with patch .object (Figshare , "urlopen" , new = mock_urlopen ):
139158 with TemporaryDirectory () as d :
140- fig = Figshare ()
141-
142159 output = []
143- for l in fig .fetch (test_spec , d ):
160+ for l in test_fig .fetch (test_spec , d ):
144161 output .append (l )
145162
146163 unpacked_files = set (os .listdir (d ))
0 commit comments