File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
oc4ids_datastore_pipeline Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,13 @@ def fetch_registered_datasets() -> dict[str, str]:
22
22
}
23
23
registered_datasets_count = len (registered_datasets )
24
24
logger .info (f"Fetched URLs for { registered_datasets_count } datasets" )
25
- return registered_datasets
26
25
except Exception as e :
27
26
raise Exception ("Failed to fetch datasets list from registry" , e )
27
+ if registered_datasets_count < 1 :
28
+ raise Exception (
29
+ "Zero datasets returned from registry, likely an upstream error"
30
+ )
31
+ return registered_datasets
28
32
29
33
30
34
def fetch_license_mappings () -> dict [str , str ]:
Original file line number Diff line number Diff line change @@ -38,6 +38,20 @@ def test_fetch_registered_datasets_raises_failure_exception(
38
38
assert "Mocked exception" in str (exc_info .value )
39
39
40
40
41
+ def test_fetch_registered_datasets_raises_exception_when_no_datasets (
42
+ mocker : MockerFixture ,
43
+ ) -> None :
44
+ mock_response = MagicMock ()
45
+ mock_response .json .return_value = {"records" : {}}
46
+ patch_get = mocker .patch ("oc4ids_datastore_pipeline.pipeline.requests.get" )
47
+ patch_get .return_value = mock_response
48
+
49
+ with pytest .raises (Exception ) as exc_info :
50
+ fetch_registered_datasets ()
51
+
52
+ assert "Zero datasets returned from registry" in str (exc_info .value )
53
+
54
+
41
55
def test_fetch_license_mappings (mocker : MockerFixture ) -> None :
42
56
mock_response = MagicMock ()
43
57
mock_response .json .return_value = {
You can’t perform that action at this time.
0 commit comments