lightning/tests/tests_app_examples/test_boring_app.py

39 lines
1.0 KiB
Python
Raw Normal View History

import os
import pytest
2022-08-10 09:48:06 +00:00
from click.testing import CliRunner
from tests_app import _PROJECT_ROOT
2022-08-10 09:48:06 +00:00
from lightning_app.cli.lightning_cli import logs
from lightning_app.testing.testing import run_app_in_cloud, wait_for
@pytest.mark.cloud
def test_boring_app_example_cloud() -> None:
with run_app_in_cloud(
os.path.join(_PROJECT_ROOT, "examples/app_boring/"),
app_name="app_dynamic.py",
debug=False,
) as (
_,
view_page,
2022-08-10 20:34:23 +00:00
fetch_logs,
2022-08-10 09:48:06 +00:00
name,
):
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)
print("Succeeded App!")