3
3
from time import sleep
4
4
5
5
import pytest
6
- import requests
7
6
from integrations_app .public import _PATH_EXAMPLES
8
7
9
8
from lightning_app .testing .testing import run_app_in_cloud
10
- from lightning_app .utilities .cloud import _get_project
11
- from lightning_app .utilities .network import LightningClient
12
9
13
10
14
11
@pytest .mark .timeout (300 )
15
12
@pytest .mark .cloud
16
13
def test_commands_and_api_example_cloud () -> None :
17
14
with run_app_in_cloud (os .path .join (_PATH_EXAMPLES , "app_commands_and_api" )) as (
18
15
admin_page ,
19
- _ ,
16
+ view_page ,
20
17
fetch_logs ,
21
18
app_name ,
22
19
):
@@ -25,29 +22,12 @@ def test_commands_and_api_example_cloud() -> None:
25
22
cmd_1 = f"python -m lightning connect { app_name } "
26
23
cmd_2 = "python -m lightning command with client --name=this"
27
24
cmd_3 = "python -m lightning command without client --name=is"
28
- cmd_4 = "lightning disconnect"
29
- process = Popen (" && " .join ([cmd_1 , cmd_2 , cmd_3 , cmd_4 ]), shell = True )
25
+ cmd_4 = "python -m lightning command without client --name=awesome"
26
+ cmd_5 = "lightning disconnect"
27
+ process = Popen (" && " .join ([cmd_1 , cmd_2 , cmd_3 , cmd_4 , cmd_5 ]), shell = True )
30
28
process .wait ()
31
29
32
- # This prevents some flakyness in the CI. Couldn't reproduce it locally.
33
- sleep (5 )
34
-
35
- # Send a request to the Rest API directly.
36
- client = LightningClient ()
37
- project = _get_project (client )
38
-
39
- lit_apps = [
40
- lit_app
41
- for lit_app in client .lightningapp_instance_service_list_lightningapp_instances (
42
- project_id = project .project_id ,
43
- ).lightningapps
44
- if lit_app .name == app_name
45
- ]
46
- app = lit_apps [0 ]
47
-
48
- base_url = app .status .url
49
- resp = requests .post (base_url + "/user/command_without_client?name=awesome" )
50
- assert resp .status_code == 200 , resp .json ()
30
+ "/" .join (view_page .url .split ("/" )[:- 2 ])
51
31
52
32
# Validate the logs.
53
33
has_logs = False
@@ -56,8 +36,3 @@ def test_commands_and_api_example_cloud() -> None:
56
36
if "['this', 'is', 'awesome']" in log :
57
37
has_logs = True
58
38
sleep (1 )
59
-
60
- # Send a request to the Rest API directly.
61
- resp = requests .get (base_url + "/pure_function" )
62
- assert resp .status_code == 200
63
- assert resp .json () == "Hello World !"
0 commit comments