🔧 chore(test_cli.py): refactor test_components_path to use a temporary directory for components path
🔧 chore(test_cli.py): refactor test_components_path to use a temporary directory for components path to improve test isolation and avoid side effects
This commit is contained in:
parent
d75fb49bf2
commit
41707c1eac
1 changed files with 9 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from tempfile import tempdir
|
||||||
from langflow.__main__ import app
|
from langflow.__main__ import app
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -39,11 +40,16 @@ def test_database_url(runner):
|
||||||
|
|
||||||
|
|
||||||
def test_components_path(runner, client, default_settings):
|
def test_components_path(runner, client, default_settings):
|
||||||
|
# Create a foldr in the tmp directory
|
||||||
|
temp_dir = Path(tempdir)
|
||||||
|
# create a "components" folder
|
||||||
|
temp_dir = temp_dir / "components"
|
||||||
|
temp_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
app,
|
app,
|
||||||
["--components-path", "./", *default_settings],
|
["--components-path", str(temp_dir), *default_settings],
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0, result.stdout
|
assert result.exit_code == 0, result.stdout
|
||||||
settings_manager = utils.get_settings_manager()
|
settings_manager = utils.get_settings_manager()
|
||||||
path = Path("./")
|
assert temp_dir in settings_manager.settings.COMPONENTS_PATH
|
||||||
assert path in settings_manager.settings.COMPONENTS_PATH
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue