@@ -1422,9 +1422,6 @@ def test_open(self, monkeypatch):
1422
1422
1423
1423
mock_client .cloud_space_service_create_cloud_space .return_value = V1CloudSpace (id = "cloudspace_id" )
1424
1424
mock_client .cloud_space_service_create_lightning_run .return_value = V1LightningRun (id = "run_id" )
1425
- mock_client .cloud_space_service_create_lightning_run_instance .return_value = Externalv1LightningappInstance (
1426
- id = "instance_id"
1427
- )
1428
1425
1429
1426
mock_client .cluster_service_list_clusters .return_value = V1ListClustersResponse ([Externalv1Cluster (id = "test" )])
1430
1427
cloud_backend = mock .MagicMock ()
@@ -1445,9 +1442,6 @@ def test_open(self, monkeypatch):
1445
1442
cloudspace_id = "cloudspace_id" ,
1446
1443
body = mock .ANY ,
1447
1444
)
1448
- mock_client .cloud_space_service_create_lightning_run_instance .assert_called_once_with (
1449
- project_id = "test-project-id" , cloudspace_id = "cloudspace_id" , id = "run_id" , body = mock .ANY
1450
- )
1451
1445
1452
1446
assert mock_client .cloud_space_service_create_cloud_space .call_args .kwargs ["body" ].name == "test_space"
1453
1447
@@ -1565,10 +1559,6 @@ def test_reopen(self, monkeypatch, capsys):
1565
1559
body = mock .ANY ,
1566
1560
)
1567
1561
1568
- mock_client .lightningapp_instance_service_update_lightningapp_instance_release .assert_called_once_with (
1569
- project_id = "test-project-id" , id = "instance_id" , body = Body4 (release_id = "run_id" )
1570
- )
1571
-
1572
1562
out , _ = capsys .readouterr ()
1573
1563
assert "will not overwrite the files in your CloudSpace." in out
1574
1564
@@ -2012,12 +2002,11 @@ def run(self):
2012
2002
2013
2003
2014
2004
@pytest .mark .parametrize (
2015
- "project, cloudspace_name, run_instance, user, tab, lightning_cloud_url, expected_url" ,
2005
+ "project, run_instance, user, tab, lightning_cloud_url, expected_url" ,
2016
2006
[
2017
2007
# Old style
2018
2008
(
2019
2009
V1Membership (),
2020
- "any" ,
2021
2010
Externalv1LightningappInstance (id = "test-app-id" ),
2022
2011
V1GetUserResponse (username = "tester" , features = V1UserFeatures ()),
2023
2012
"logs" ,
@@ -2026,7 +2015,6 @@ def run(self):
2026
2015
),
2027
2016
(
2028
2017
V1Membership (),
2029
- "any" ,
2030
2018
Externalv1LightningappInstance (id = "test-app-id" ),
2031
2019
V1GetUserResponse (username = "tester" , features = V1UserFeatures ()),
2032
2020
"logs" ,
@@ -2036,25 +2024,58 @@ def run(self):
2036
2024
# New style
2037
2025
(
2038
2026
V1Membership (name = "tester's project" ),
2039
- "test/app" ,
2040
- Externalv1LightningappInstance (),
2027
+ Externalv1LightningappInstance (name = "test/job" ),
2041
2028
V1GetUserResponse (username = "tester" , features = V1UserFeatures (project_selector = True )),
2042
2029
"logs" ,
2043
2030
"https://lightning.ai" ,
2044
- "https://lightning.ai/tester/tester%27s_project/apps /test~app /logs" ,
2031
+ "https://lightning.ai/tester/tester%27s%20project/jobs /test%2Fjob /logs" ,
2045
2032
),
2046
2033
(
2047
2034
V1Membership (name = "tester's project" ),
2048
- "test/app" ,
2049
- Externalv1LightningappInstance (),
2035
+ Externalv1LightningappInstance (name = "test/job" ),
2050
2036
V1GetUserResponse (username = "tester" , features = V1UserFeatures (project_selector = True )),
2051
2037
"logs" ,
2038
+ "https://localhost:9800" ,
2039
+ "https://localhost:9800/tester/tester%27s%20project/jobs/test%2Fjob/logs" ,
2040
+ ),
2041
+ ],
2042
+ )
2043
+ def test_get_app_url (monkeypatch , project , run_instance , user , tab , lightning_cloud_url , expected_url ):
2044
+ mock_client = mock .MagicMock ()
2045
+ mock_client .auth_service_get_user .return_value = user
2046
+ cloud_backend = mock .MagicMock (client = mock_client )
2047
+ monkeypatch .setattr (backends , "CloudBackend" , mock .MagicMock (return_value = cloud_backend ))
2048
+
2049
+ runtime = CloudRuntime ()
2050
+
2051
+ with mock .patch (
2052
+ "lightning.app.runners.cloud.get_lightning_cloud_url" , mock .MagicMock (return_value = lightning_cloud_url )
2053
+ ):
2054
+ assert runtime ._get_app_url (project , run_instance , tab ) == expected_url
2055
+
2056
+
2057
+ @pytest .mark .parametrize (
2058
+ "user, project, cloudspace_name, tab, lightning_cloud_url, expected_url" ,
2059
+ [
2060
+ (
2061
+ V1GetUserResponse (username = "tester" , features = V1UserFeatures ()),
2062
+ V1Membership (name = "default-project" ),
2063
+ "test/cloudspace" ,
2064
+ "code" ,
2065
+ "https://lightning.ai" ,
2066
+ "https://lightning.ai/tester/default-project/apps/test%2Fcloudspace/code" ,
2067
+ ),
2068
+ (
2069
+ V1GetUserResponse (username = "tester" , features = V1UserFeatures ()),
2070
+ V1Membership (name = "Awesome Project" ),
2071
+ "The Best CloudSpace ever" ,
2072
+ "web-ui" ,
2052
2073
"http://localhost:9800" ,
2053
- "http://localhost:9800/tester/tester%27s_project /apps/test~app/logs " ,
2074
+ "http://localhost:9800/tester/Awesome%20Project /apps/The%20Best%20CloudSpace%20ever/web-ui " ,
2054
2075
),
2055
2076
],
2056
2077
)
2057
- def test_get_app_url (monkeypatch , project , cloudspace_name , run_instance , user , tab , lightning_cloud_url , expected_url ):
2078
+ def test_get_cloudspace_url (monkeypatch , user , project , cloudspace_name , tab , lightning_cloud_url , expected_url ):
2058
2079
mock_client = mock .MagicMock ()
2059
2080
mock_client .auth_service_get_user .return_value = user
2060
2081
cloud_backend = mock .MagicMock (client = mock_client )
@@ -2065,4 +2086,4 @@ def test_get_app_url(monkeypatch, project, cloudspace_name, run_instance, user,
2065
2086
with mock .patch (
2066
2087
"lightning.app.runners.cloud.get_lightning_cloud_url" , mock .MagicMock (return_value = lightning_cloud_url )
2067
2088
):
2068
- assert runtime ._get_app_url (project , cloudspace_name , run_instance , tab ) == expected_url
2089
+ assert runtime ._get_cloudspace_url (project , cloudspace_name , tab ) == expected_url
0 commit comments