@@ -68,6 +68,7 @@ class MockClusterNotUpError(Exception):
6868 "sky.core" : sky_core_mock ,
6969 "sky.skylet.job_lib" : job_lib_mock ,
7070 "sky.utils.common_utils" : common_utils_mock ,
71+ "sky.resources" : MagicMock (),
7172 }
7273
7374 # Also mock the sky_exceptions module with our mock exception
@@ -141,6 +142,33 @@ def test_init_non_git_packager(self, mock_skypilot_imports):
141142 packager = non_git_packager ,
142143 )
143144
145+ def test_init_with_infra_and_cloud_fails (self , mock_skypilot_imports ):
146+ with pytest .raises (
147+ AssertionError , match = "Cannot specify both `infra` and `cloud` parameters."
148+ ):
149+ SkypilotExecutor (
150+ infra = "my-infra" ,
151+ cloud = "aws" ,
152+ )
153+
154+ def test_init_with_infra_and_region_fails (self , mock_skypilot_imports ):
155+ with pytest .raises (
156+ AssertionError , match = "Cannot specify both `infra` and `region` parameters."
157+ ):
158+ SkypilotExecutor (
159+ infra = "my-infra" ,
160+ region = "us-west-2" ,
161+ )
162+
163+ def test_init_with_infra_and_zone_fails (self , mock_skypilot_imports ):
164+ with pytest .raises (
165+ AssertionError , match = "Cannot specify both `infra` and `zone` parameters."
166+ ):
167+ SkypilotExecutor (
168+ infra = "my-infra" ,
169+ zone = "us-west-2a" ,
170+ )
171+
144172 def test_parse_app (self , mock_skypilot_imports ):
145173 app_id = "app___cluster-name___task-name___123"
146174 cluster , task , job_id = SkypilotExecutor .parse_app (app_id )
@@ -228,6 +256,18 @@ def test_to_resources_with_none_string(self, mock_resources, mock_skypilot_impor
228256 assert config ["cloud" ] is None
229257 assert config ["any_of" ][1 ]["region" ] is None
230258
259+ @patch ("sky.resources.Resources" )
260+ def test_to_resources_with_infra_and_network_tier (self , mock_resources , mock_skypilot_imports ):
261+ executor = SkypilotExecutor (infra = "k8s/my-context" , network_tier = "best" )
262+
263+ executor .to_resources ()
264+
265+ mock_resources .from_yaml_config .assert_called_once ()
266+
267+ config = mock_resources .from_yaml_config .call_args [0 ][0 ]
268+ assert config ["infra" ] == "k8s/my-context"
269+ assert config ["network_tier" ] == "best"
270+
231271 @patch ("sky.core.status" )
232272 @patch ("sky.core.queue" )
233273 @patch ("nemo_run.core.execution.skypilot.SkypilotExecutor.parse_app" )
0 commit comments