Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/specify_cli/extensions/command_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,6 @@ def extension_add(
"Verify the extension manifest and template files."
)

# Only warn when configuration is actually unresolved. Scaffolding that
# deployed or preserved every template has already answered this, and an
# extension without provides.config has nothing to configure; the blanket
# warning contradicted the output directly above it.
if failed or not (deployed or skipped):
console.print("\n[yellow]⚠[/yellow] Configuration may be required")
console.print(f" Check: {config_home}/")

Expand Down
30 changes: 30 additions & 0 deletions tests/specify_cli/extensions/test_command_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@
class TestExtensionAddCLI:
"""CLI tests for ``specify extension add``."""

@pytest.mark.parametrize(
("config", "warns"),
[
pytest.param({}, False, id="undeclared"),
pytest.param({"config": []}, False, id="empty"),
pytest.param(
{"config": [{"name": "test-ext-config.yml", "template": "missing.yml"}]},
True,
id="missing-template",
),
],
)
def test_add_dev_warns_only_when_config_scaffolding_fails(
self, extension_dir, project_dir, valid_manifest_data, config, warns
):
valid_manifest_data["provides"].update(config)
(extension_dir / "extension.yml").write_text(
yaml.safe_dump(valid_manifest_data), encoding="utf-8"
)

with patch.object(Path, "cwd", return_value=project_dir):
result = CliRunner().invoke(app, ["extension", "add", "--dev", str(extension_dir)])

assert result.exit_code == 0, result.output
output = strip_ansi(result.output)
assert "Extension installed successfully" in output
assert ("Configuration may be required" in output) == warns, output
assert ("Config templates not scaffolded" in output) == warns, output

@pytest.mark.parametrize("command", [
pytest.param(["speckit.test-ext.hello"], id="list"),
pytest.param({"name": "speckit.test-ext.hello"}, id="mapping"),
Expand Down Expand Up @@ -722,6 +751,7 @@ def fake_install_from_zip(
patch("specify_cli.authentication.http.open_url", return_value=FakeResponse(_MINIMAL_ZIP_BYTES)), \
patch("specify_cli.extensions._commands._safe_open_download_zip", side_effect=_open_test_download_zip), \
patch.object(ExtensionManager, "install_from_zip", fake_install_from_zip), \
patch.object(ExtensionManager, "scaffold_config", return_value=([], [], ["test-ext-config.yml"])), \
patch.object(ExtensionRegistry, "get", return_value={}):
result = runner.invoke(
app,
Expand Down