@@ -110,6 +110,46 @@ def test_read_config_files(self):
110110 self .assertEqual (self .publisher .dataset_config , dataset_config )
111111 self .assertEqual (self .publisher .workflow_config , workflow_config )
112112
113+ @patch ("deep_code.tools.publish.GitHubPublisher" )
114+ def test_environment_repo_selection (self , mock_gp ):
115+ Publisher (environment = "production" )
116+ assert mock_gp .call_args .kwargs ["repo_name" ] == "open-science-catalog-metadata"
117+ Publisher (environment = "staging" )
118+ assert (
119+ mock_gp .call_args .kwargs ["repo_name" ]
120+ == "open-science-catalog-metadata-staging"
121+ )
122+ Publisher (environment = "testing" )
123+ assert (
124+ mock_gp .call_args .kwargs ["repo_name" ]
125+ == "open-science-catalog-metadata-testing"
126+ )
127+
128+ @patch .object (Publisher , "publish_dataset" , return_value = {"a" : {}})
129+ @patch .object (
130+ Publisher , "generate_workflow_experiment_records" , return_value = {"b" : {}}
131+ )
132+ def test_publish_mode_routing (self , mock_wf , mock_ds ):
133+ # dataset only
134+ self .publisher .publish (write_to_file = True , mode = "dataset" )
135+ mock_ds .assert_called ()
136+ mock_wf .assert_not_called ()
137+
138+ mock_ds .reset_mock ()
139+ mock_wf .reset_mock ()
140+ self .publisher .publish (write_to_file = True , mode = "workflow" )
141+ mock_ds .assert_not_called ()
142+ mock_wf .assert_called ()
143+
144+ @patch .object (Publisher , "generate_workflow_experiment_records" , return_value = {})
145+ @patch .object (Publisher , "publish_dataset" , return_value = {})
146+ def test_publish_nothing_to_publish_raises (
147+ self , mock_publish_dataset , mock_generate_workflow_experiment_records
148+ ):
149+ with pytest .raises (ValueError ):
150+ self .publisher .publish (write_to_file = False , mode = "dataset" )
151+ mock_publish_dataset .assert_called_once ()
152+ mock_generate_workflow_experiment_records .assert_not_called ()
113153
114154class TestParseGithubNotebookUrl :
115155 @pytest .mark .parametrize (
0 commit comments