2022-06-30 20:45:15 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
2022-08-10 09:48:06 +00:00
|
|
|
from click.testing import CliRunner
|
2022-06-30 20:45:15 +00:00
|
|
|
from tests_app import _PROJECT_ROOT
|
|
|
|
|
2022-08-10 09:48:06 +00:00
|
|
|
from lightning_app.cli.lightning_cli import logs
|
2022-06-30 20:45:15 +00:00
|
|
|
from lightning_app.testing.testing import run_app_in_cloud, wait_for
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.cloud
|
|
|
|
def test_boring_app_example_cloud() -> None:
|
2022-09-13 14:50:36 +00:00
|
|
|
with run_app_in_cloud(
|
|
|
|
os.path.join(_PROJECT_ROOT, "examples/app_boring/"),
|
|
|
|
app_name="app_dynamic.py",
|
|
|
|
debug=False,
|
|
|
|
) as (
|
2022-06-30 20:45:15 +00:00
|
|
|
_,
|
|
|
|
view_page,
|
2022-08-10 20:34:23 +00:00
|
|
|
fetch_logs,
|
2022-08-10 09:48:06 +00:00
|
|
|
name,
|
2022-06-30 20:45:15 +00:00
|
|
|
):
|
|
|
|
|
|
|
|
def check_hello_there(*_, **__):
|
|
|
|
locator = view_page.frame_locator("iframe").locator('ul:has-text("Hello there!")')
|
|
|
|
if len(locator.all_text_contents()):
|
|
|
|
return True
|
|
|
|
|
|
|
|
wait_for(view_page, check_hello_there)
|
2022-08-10 09:48:06 +00:00
|
|
|
|
|
|
|
runner = CliRunner()
|
|
|
|
result = runner.invoke(logs, [name])
|
|
|
|
lines = result.output.splitlines()
|
|
|
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.exception is None
|
2022-08-10 17:26:01 +00:00
|
|
|
assert any("http://0.0.0.0:8080" in line for line in lines)
|
2022-09-13 14:50:36 +00:00
|
|
|
print("Succeeded App!")
|