@@ -104,6 +104,23 @@ def test_get_workspace_info_from_databricks_secrets():
104
104
def test_get_workspace_info_from_dbutils ():
105
105
mock_dbutils = mock .MagicMock ()
106
106
mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .browserHostName .return_value .get .return_value = ( # noqa
107
+ "mlflow.databricks.com"
108
+ )
109
+ mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .workspaceId .return_value .get .return_value = ( # noqa
110
+ "1111"
111
+ )
112
+ with mock .patch ("mlflow.utils.databricks_utils._get_dbutils" , return_value = mock_dbutils ):
113
+ workspace_host , workspace_id = get_workspace_info_from_dbutils ()
114
+ assert workspace_host == "https://mlflow.databricks.com"
115
+ assert workspace_id == "1111"
116
+
117
+
118
+ def test_get_workspace_info_from_dbutils_no_browser_host_name ():
119
+ mock_dbutils = mock .MagicMock ()
120
+ mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .browserHostName .return_value .get .return_value = ( # noqa
121
+ None
122
+ )
123
+ mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .apiUrl .return_value .get .return_value = ( # noqa
107
124
"https://mlflow.databricks.com"
108
125
)
109
126
mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .workspaceId .return_value .get .return_value = ( # noqa
@@ -121,7 +138,7 @@ def test_get_workspace_info_from_dbutils_old_runtimes():
121
138
'{"tags": {"orgId" : "1111", "browserHostName": "mlflow.databricks.com"}}'
122
139
)
123
140
mock_dbutils .notebook .entry_point .getDbutils .return_value .notebook .return_value .getContext .return_value .browserHostName .return_value .get .return_value = ( # noqa
124
- "https:// mlflow.databricks.com"
141
+ "mlflow.databricks.com"
125
142
)
126
143
# Mock out workspace ID tag
127
144
mock_workspace_id_tag_opt = mock .MagicMock ()
0 commit comments