remove test parameterization and use fix regex match
@@ -49,10 +49,9 @@ test_hosts = [
)
]
-@pytest.mark.parametrize("test_input", test_hosts)
-def test_detect_hydroshare(test_input):
+def test_detect_hydroshare():
with patch.object(Hydroshare, "urlopen") as fake_urlopen:
- fake_urlopen.return_value.url = test_input[0]
+ fake_urlopen.return_value.url = "https://www.hydroshare.org/resource/b8f6eae9d89241cf8b5904033460af61"
def read():
return '{"dates": [{"type": "modified", "start_date": "2019-09-25T16:09:17.006152Z"}]}'
@@ -60,13 +59,13 @@ def test_detect_hydroshare(test_input):
fake_urlopen.return_value.read = read
# valid Hydroshare DOIs trigger this content provider
expected = "https://www.hydroshare.org/resource/b8f6eae9d89241cf8b5904033460af61"
- assert Hydroshare().detect(test_input[0]) == expected
+ assert Hydroshare().detect("https://www.hydroshare.org/resource/b8f6eae9d89241cf8b5904033460af61") == expected
# assert a call to urlopen was called to fetch version
assert fake_urlopen.call_count == 1
- assert Hydroshare().detect(test_input[1]) == expected
+ assert Hydroshare().detect("10.4211/hs.b8f6eae9d89241cf8b5904033460af61") == expected
# assert 2 more calls were made, one to resolve the DOI and another to fetch the version
assert fake_urlopen.call_count == 3
- assert Hydroshare().detect(test_input[2]) == expected
+ assert Hydroshare().detect("https://doi.org/10.4211/hs.b8f6eae9d89241cf8b5904033460af61") == expected
# assert 2 more calls were made, one to resolve the DOI and another to fetch the version
assert fake_urlopen.call_count == 5
@@ -174,7 +173,7 @@ def test_fetch_bag_failure():
"resource": "123456789",
}
with TemporaryDirectory() as d:
- with pytest.raises(ContentProviderException, match="Failed to download bag. status code 500.\n"):
+ with pytest.raises(ContentProviderException, match=r"Failed to download bag. status code 500.\n"):
hydro.fetch(spec, d)
@@ -196,5 +195,5 @@ def test_fetch_bag_timeout():
}
with TemporaryDirectory() as d:
with pytest.raises(ContentProviderException,
- match="Bag taking too long to prepare, exiting now, try again later."):
+ match=r"Bag taking too long to prepare, exiting now, try again later."):
hydro.fetch(spec, d, timeout=0)
