@@ -34,20 +34,14 @@ def doi_resolver(req, context):
3434}
3535
3636
37- def test_content_id (requests_mock ):
38- requests_mock .get (re .compile ("https://" ), json = hydroshare_data )
39- requests_mock .get (re .compile ("https://doi.org" ), json = doi_resolver )
40-
37+ def test_content_id ():
4138 hydro = Hydroshare ()
4239
4340 hydro .detect ("10.4211/hs.b8f6eae9d89241cf8b5904033460af61" )
44- assert hydro .content_id == "b8f6eae9d89241cf8b5904033460af61.v1569427757"
45-
41+ assert hydro .content_id == "b8f6eae9d89241cf8b5904033460af61.v1585005408"
4642
47- def test_detect_hydroshare (requests_mock ):
48- requests_mock .get (re .compile ("https://" ), json = hydroshare_data )
49- requests_mock .get (re .compile ("https://doi.org" ), json = doi_resolver )
5043
44+ def test_detect_hydroshare ():
5145 # valid Hydroshare DOIs trigger this content provider
5246 expected = {
5347 "host" : {
@@ -59,7 +53,7 @@ def test_detect_hydroshare(requests_mock):
5953 "version" : "https://www.hydroshare.org/hsapi/resource/{}/scimeta/elements" ,
6054 },
6155 "resource" : "b8f6eae9d89241cf8b5904033460af61" ,
62- "version" : "1569427757 " ,
56+ "version" : "1585005408 " ,
6357 }
6458
6559 assert (
@@ -68,26 +62,17 @@ def test_detect_hydroshare(requests_mock):
6862 )
6963 == expected
7064 )
71- # assert a call to urlopen was called to fetch version
72- assert requests_mock .call_count == 1
73- requests_mock .reset_mock ()
7465
7566 assert (
7667 Hydroshare ().detect ("10.4211/hs.b8f6eae9d89241cf8b5904033460af61" ) == expected
7768 )
78- # assert 3 calls were made, 2 to resolve the DOI (302 + 200) and another to fetch the version
79- assert requests_mock .call_count == 3
80- requests_mock .reset_mock ()
8169
8270 assert (
8371 Hydroshare ().detect (
8472 "https://doi.org/10.4211/hs.b8f6eae9d89241cf8b5904033460af61"
8573 )
8674 == expected
8775 )
88- # assert 3 more calls were made, 2 to resolve the DOI and another to fetch the version
89- assert requests_mock .call_count == 3
90- requests_mock .reset_mock ()
9176
9277 # Don't trigger the Hydroshare content provider
9378 assert Hydroshare ().detect ("/some/path/here" ) is None
0 commit comments