🔧 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:
Gabriel Luiz Freitas Almeida 2023-08-07 11:59:23 -03:00
commit 41707c1eac

View file

@ -1,4 +1,5 @@
from pathlib import Path
from tempfile import tempdir
from langflow.__main__ import app
import pytest
@ -39,11 +40,16 @@ def test_database_url(runner):
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(
app,
["--components-path", "./", *default_settings],
["--components-path", str(temp_dir), *default_settings],
)
assert result.exit_code == 0, result.stdout
settings_manager = utils.get_settings_manager()
path = Path("./")
assert path in settings_manager.settings.COMPONENTS_PATH
assert temp_dir in settings_manager.settings.COMPONENTS_PATH