8
8
from click .testing import CliRunner
9
9
from tests_app import _PROJECT_ROOT
10
10
11
+ import lightning_app .core .constants as constants
11
12
from lightning_app import LightningApp
12
13
from lightning_app .cli .lightning_cli import _run_app , run_app
13
14
from lightning_app .runners .runtime_type import RuntimeType
@@ -45,7 +46,11 @@ def _lightning_app_run_and_logging(self, *args, **kwargs):
45
46
)
46
47
# capture logs.
47
48
if open_ui :
48
- lauch_mock .assert_called_with ("http://127.0.0.1:7501/view" )
49
+
50
+ # Get the designated port
51
+ port = constants .APP_SERVER_PORT
52
+
53
+ lauch_mock .assert_called_with (f"http://127.0.0.1:{ port } /view" )
49
54
else :
50
55
lauch_mock .assert_not_called ()
51
56
assert result .exit_code == 0
@@ -99,6 +104,10 @@ def test_lightning_run_app_cloud(mock_dispatch: mock.MagicMock, open_ui, caplog,
99
104
run_app_comment_commands = False ,
100
105
enable_basic_auth = "" ,
101
106
)
107
+
108
+ # Get the designated port
109
+ port = constants .APP_SERVER_PORT
110
+
102
111
# capture logs.
103
112
# TODO(yurij): refactor the test, check if the actual HTTP request is being sent and that the proper admin
104
113
# page is being opened
@@ -115,7 +124,7 @@ def test_lightning_run_app_cloud(mock_dispatch: mock.MagicMock, open_ui, caplog,
115
124
cluster_id = "" ,
116
125
run_app_comment_commands = False ,
117
126
enable_basic_auth = "" ,
118
- port = 7501 ,
127
+ port = port ,
119
128
)
120
129
121
130
@@ -145,6 +154,10 @@ def test_lightning_run_app_cloud_with_run_app_commands(mock_dispatch: mock.Magic
145
154
run_app_comment_commands = True ,
146
155
enable_basic_auth = "" ,
147
156
)
157
+
158
+ # Get the designated port
159
+ port = constants .APP_SERVER_PORT
160
+
148
161
# capture logs.
149
162
# TODO(yurij): refactor the test, check if the actual HTTP request is being sent and that the proper admin
150
163
# page is being opened
@@ -161,7 +174,7 @@ def test_lightning_run_app_cloud_with_run_app_commands(mock_dispatch: mock.Magic
161
174
cluster_id = "" ,
162
175
run_app_comment_commands = True ,
163
176
enable_basic_auth = "" ,
164
- port = 7501 ,
177
+ port = port ,
165
178
)
166
179
167
180
@@ -211,6 +224,9 @@ def test_lightning_run_app_enable_basic_auth_passed(mock_dispatch: mock.MagicMoc
211
224
enable_basic_auth = "username:password" ,
212
225
)
213
226
227
+ # Get the designated port
228
+ port = constants .APP_SERVER_PORT
229
+
214
230
mock_dispatch .assert_called_with (
215
231
Path (os .path .join (_PROJECT_ROOT , "tests/tests_app/core/scripts/app_metadata.py" )),
216
232
RuntimeType .CLOUD ,
@@ -224,5 +240,5 @@ def test_lightning_run_app_enable_basic_auth_passed(mock_dispatch: mock.MagicMoc
224
240
cluster_id = "" ,
225
241
run_app_comment_commands = False ,
226
242
enable_basic_auth = "username:password" ,
227
- port = 7501 ,
243
+ port = port ,
228
244
)
0 commit comments