@@ -126,11 +126,22 @@ def test_environment_repo_selection(self, mock_gp):
126126 == "open-science-catalog-metadata-testing"
127127 )
128128
129+ @patch .object (Publisher , "_write_stac_catalog_to_s3" )
129130 @patch .object (Publisher , "publish_dataset" , return_value = {"a" : {}})
130131 @patch .object (
131132 Publisher , "generate_workflow_experiment_records" , return_value = {"b" : {}}
132133 )
133- def test_publish_mode_routing (self , mock_wf , mock_ds ):
134+ def test_publish_mode_routing (self , mock_wf , mock_ds , mock_s3 ):
135+ mock_generator = MagicMock ()
136+ mock_generator .build_zarr_stac_catalog_file_dict .return_value = {}
137+ self .publisher ._last_generator = mock_generator
138+ self .publisher .dataset_config = {
139+ "stac_catalog_s3_root" : "s3://bucket/stac/" ,
140+ "collection_id" : "test-collection" ,
141+ "dataset_id" : "test-dataset" ,
142+ }
143+ self .publisher .gh_publisher .publish_files .return_value = "PR_URL"
144+
134145 # dataset only
135146 self .publisher .publish (write_to_file = True , mode = "dataset" )
136147 mock_ds .assert_called ()
@@ -142,28 +153,41 @@ def test_publish_mode_routing(self, mock_wf, mock_ds):
142153 mock_ds .assert_not_called ()
143154 mock_wf .assert_called ()
144155
156+ @patch .object (Publisher , "_write_stac_catalog_to_s3" )
145157 @patch .object (Publisher , "generate_workflow_experiment_records" , return_value = {})
146158 @patch .object (Publisher , "publish_dataset" , return_value = {})
147159 def test_publish_nothing_to_publish_raises (
148- self , mock_publish_dataset , mock_generate_workflow_experiment_records
160+ self , mock_publish_dataset , mock_generate_workflow_experiment_records , mock_s3
149161 ):
162+ mock_generator = MagicMock ()
163+ mock_generator .build_zarr_stac_catalog_file_dict .return_value = {}
164+ self .publisher ._last_generator = mock_generator
165+ self .publisher .dataset_config = {"stac_catalog_s3_root" : "s3://bucket/stac/" }
166+
150167 with pytest .raises (ValueError ):
151168 self .publisher .publish (write_to_file = False , mode = "dataset" )
152169 mock_publish_dataset .assert_called_once ()
153170 mock_generate_workflow_experiment_records .assert_not_called ()
154171
172+ @patch .object (Publisher , "_write_stac_catalog_to_s3" )
155173 @patch .object (Publisher , "publish_dataset" , return_value = {"x" : {}})
156174 @patch .object (
157175 Publisher , "generate_workflow_experiment_records" , return_value = {"y" : {}}
158176 )
159- def test_publish_builds_pr_params (self , mock_wf , mock_ds ):
177+ def test_publish_builds_pr_params (self , mock_wf , mock_ds , mock_s3 ):
160178 # Make PR creation return a fixed URL
161179 self .publisher .gh_publisher .publish_files .return_value = "PR_URL"
162180
163181 # Provide IDs for commit/PR labels
164182 self .publisher .collection_id = "col"
165183 self .publisher .workflow_id = "wf"
166184
185+ # _last_generator is set by publish_dataset; since that's mocked, stub it
186+ mock_generator = MagicMock ()
187+ mock_generator .build_zarr_stac_catalog_file_dict .return_value = {}
188+ self .publisher ._last_generator = mock_generator
189+ self .publisher .dataset_config = {"stac_catalog_s3_root" : "s3://bucket/stac/" }
190+
167191 url = self .publisher .publish (write_to_file = False , mode = "all" )
168192 assert url == "PR_URL"
169193
@@ -309,6 +333,7 @@ def test_publish_dataset_creates_project_collection_when_missing(
309333 "dataset_id" : "test-dataset" ,
310334 "collection_id" : "test-collection" ,
311335 "license_type" : "CC-BY-4.0" ,
336+ "stac_catalog_s3_root" : "s3://bucket/stac/test-collection/" ,
312337 }
313338 self .publisher .collection_id = "test-collection"
314339
@@ -343,6 +368,7 @@ def test_publish_dataset_updates_project_collection_when_exists(
343368 "dataset_id" : "test-dataset" ,
344369 "collection_id" : "test-collection" ,
345370 "license_type" : "CC-BY-4.0" ,
371+ "stac_catalog_s3_root" : "s3://bucket/stac/test-collection/" ,
346372 }
347373 self .publisher .collection_id = "test-collection"
348374
@@ -359,20 +385,15 @@ def test_publish_dataset_updates_project_collection_when_exists(
359385 update_methods = [call .args [2 ] for call in mock_update .call_args_list ]
360386 self .assertIn (mock_gen .update_deepesdl_collection , update_methods )
361387
362- @patch .object (Publisher , "publish_dataset" , return_value = {"github_file.json" : {}})
363- def test_publish_skips_zarr_stac_when_not_configured (self , mock_publish_ds ):
364- # No stac_catalog_s3_root in config
388+ def test_publish_dataset_raises_when_stac_root_missing (self ):
389+ # stac_catalog_s3_root is mandatory; publish_dataset must raise ValueError
365390 self .publisher .dataset_config = {
366391 "collection_id" : "test-collection" ,
367392 "dataset_id" : "test-dataset" ,
393+ "license_type" : "CC-BY-4.0" ,
368394 }
369- self .publisher .gh_publisher .publish_files .return_value = "PR_URL"
370-
371- with patch .object (
372- self .publisher , "_write_stac_catalog_to_s3"
373- ) as mock_write :
374- self .publisher .publish (mode = "dataset" )
375- mock_write .assert_not_called ()
395+ with pytest .raises (ValueError , match = "stac_catalog_s3_root" ):
396+ self .publisher .publish_dataset (write_to_file = False )
376397
377398
378399class TestParseGithubNotebookUrl :
0 commit comments