2022-06-30 20:45:15 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from click.testing import CliRunner
|
2023-01-12 15:13:52 +00:00
|
|
|
from integrations_app.public import _PATH_EXAMPLES
|
2022-06-30 20:45:15 +00:00
|
|
|
|
2023-02-01 11:07:00 +00:00
|
|
|
from lightning.app.cli.lightning_cli import run_app
|
|
|
|
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-11-22 19:04:29 +00:00
|
|
|
_run_script(str(os.path.join(_PATH_EXAMPLES, f"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,
|
|
|
|
[
|
2022-11-22 19:04:29 +00:00
|
|
|
os.path.join(_PATH_EXAMPLES, "app_components/python/app.py"),
|
2022-06-30 20:45:15 +00:00
|
|
|
"--blocking",
|
|
|
|
"False",
|
|
|
|
"--open-ui",
|
|
|
|
"False",
|
|
|
|
],
|
|
|
|
catch_exceptions=False,
|
|
|
|
)
|
|
|
|
assert result.exit_code == 0
|
|
|
|
assert "tracer script succeed" in result.stdout
|