2022-06-30 20:45:15 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from tests_app import _PROJECT_ROOT
|
|
|
|
|
|
|
|
from lightning_app.cli.lightning_cli import run_app
|
2022-10-28 13:57:35 +00:00
|
|
|
from lightning_app.testing.helpers import _run_script, _RunIf
|
2022-06-30 20:45:15 +00:00
|
|
|
|
|
|
|
|
2022-10-28 13:57:35 +00:00
|
|
|
@_RunIf(pl=True)
|
2022-06-30 20:45:15 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"file",
|
|
|
|
[
|
|
|
|
pytest.param("component_tracer.py"),
|
2022-10-19 19:52:12 +00:00
|
|
|
pytest.param("component_popen.py"),
|
2022-06-30 20:45:15 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_scripts(file):
|
2022-10-28 13:57:35 +00:00
|
|
|
_run_script(str(os.path.join(_PROJECT_ROOT, f"examples/app_components/python/{file}")))
|
2022-06-30 20:45:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skip(reason="causing some issues with CI, not sure if the test is actually needed")
|
2022-10-28 13:57:35 +00:00
|
|
|
@_RunIf(pl=True)
|
2022-06-30 20:45:15 +00:00
|
|
|
def test_components_app_example():
|
|
|
|
|
|
|
|
runner = CliRunner()
|
|
|
|
result = runner.invoke(
|
|
|
|
run_app,
|
|
|
|
[
|
|
|
|
os.path.join(_PROJECT_ROOT, "examples/app_components/python/app.py"),
|
|
|
|
"--blocking",
|
|
|
|
"False",
|
|
|
|
"--open-ui",
|
|
|
|
"False",
|
|
|
|
],
|
|
|
|
catch_exceptions=False,
|
|
|
|
)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert "tracer script succeed" in result.stdout
|