refactor
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
"""Tests for CLI."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_version_flag():
|
||||
@@ -46,3 +44,43 @@ def test_packages_help():
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "install" in result.stdout
|
||||
|
||||
|
||||
def test_invalid_config_is_reported_without_traceback(tmp_path):
|
||||
config_root = tmp_path / "config"
|
||||
(config_root / "flow").mkdir(parents=True)
|
||||
(config_root / "flow" / "config.yaml").write_text(":\n bad\n")
|
||||
|
||||
env = dict(os.environ)
|
||||
env["XDG_CONFIG_HOME"] = str(config_root)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "flow", "completion"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env=env,
|
||||
)
|
||||
assert result.returncode == 1
|
||||
assert "Invalid YAML" in result.stderr
|
||||
assert "Traceback" not in result.stderr
|
||||
|
||||
|
||||
def test_local_manifest_is_loaded(tmp_path):
|
||||
config_root = tmp_path / "config"
|
||||
flow_dir = config_root / "flow"
|
||||
flow_dir.mkdir(parents=True)
|
||||
(flow_dir / "manifest.yaml").write_text(
|
||||
"profiles:\n"
|
||||
" demo:\n"
|
||||
" os: linux\n"
|
||||
)
|
||||
|
||||
env = dict(os.environ)
|
||||
env["XDG_CONFIG_HOME"] = str(config_root)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "flow", "setup", "list"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env=env,
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "demo" in result.stdout
|
||||
|
||||
Reference in New Issue
Block a user