@@ -34,20 +34,14 @@ def doi_resolver(req, context):
34
34
}
35
35
36
36
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 ():
41
38
hydro = Hydroshare ()
42
39
43
40
hydro .detect ("10.4211/hs.b8f6eae9d89241cf8b5904033460af61" )
44
- assert hydro .content_id == "b8f6eae9d89241cf8b5904033460af61.v1569427757"
45
-
41
+ assert hydro .content_id == "b8f6eae9d89241cf8b5904033460af61.v1585005408"
46
42
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 )
50
43
44
+ def test_detect_hydroshare ():
51
45
# valid Hydroshare DOIs trigger this content provider
52
46
expected = {
53
47
"host" : {
@@ -59,7 +53,7 @@ def test_detect_hydroshare(requests_mock):
59
53
"version" : "https://www.hydroshare.org/hsapi/resource/{}/scimeta/elements" ,
60
54
},
61
55
"resource" : "b8f6eae9d89241cf8b5904033460af61" ,
62
- "version" : "1569427757 " ,
56
+ "version" : "1585005408 " ,
63
57
}
64
58
65
59
assert (
@@ -68,26 +62,17 @@ def test_detect_hydroshare(requests_mock):
68
62
)
69
63
== expected
70
64
)
71
- # assert a call to urlopen was called to fetch version
72
- assert requests_mock .call_count == 1
73
- requests_mock .reset_mock ()
74
65
75
66
assert (
76
67
Hydroshare ().detect ("10.4211/hs.b8f6eae9d89241cf8b5904033460af61" ) == expected
77
68
)
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 ()
81
69
82
70
assert (
83
71
Hydroshare ().detect (
84
72
"https://doi.org/10.4211/hs.b8f6eae9d89241cf8b5904033460af61"
85
73
)
86
74
== expected
87
75
)
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 ()
91
76
92
77
# Don't trigger the Hydroshare content provider
93
78
assert Hydroshare ().detect ("/some/path/here" ) is None
0 commit comments