|
40 | 40 | class TestExtensionAddCLI: |
41 | 41 | """CLI tests for ``specify extension add``.""" |
42 | 42 |
|
| 43 | + @pytest.mark.parametrize( |
| 44 | + ("config", "warns"), |
| 45 | + [ |
| 46 | + pytest.param({}, False, id="undeclared"), |
| 47 | + pytest.param({"config": []}, False, id="empty"), |
| 48 | + pytest.param( |
| 49 | + {"config": [{"name": "test-ext-config.yml", "template": "missing.yml"}]}, |
| 50 | + True, |
| 51 | + id="missing-template", |
| 52 | + ), |
| 53 | + ], |
| 54 | + ) |
| 55 | + def test_add_dev_warns_only_when_config_scaffolding_fails( |
| 56 | + self, extension_dir, project_dir, valid_manifest_data, config, warns |
| 57 | + ): |
| 58 | + valid_manifest_data["provides"].update(config) |
| 59 | + (extension_dir / "extension.yml").write_text( |
| 60 | + yaml.safe_dump(valid_manifest_data), encoding="utf-8" |
| 61 | + ) |
| 62 | + |
| 63 | + with patch.object(Path, "cwd", return_value=project_dir): |
| 64 | + result = CliRunner().invoke(app, ["extension", "add", "--dev", str(extension_dir)]) |
| 65 | + |
| 66 | + assert result.exit_code == 0, result.output |
| 67 | + output = strip_ansi(result.output) |
| 68 | + assert "Extension installed successfully" in output |
| 69 | + assert ("Configuration may be required" in output) == warns, output |
| 70 | + assert ("Config templates not scaffolded" in output) == warns, output |
| 71 | + |
43 | 72 | @pytest.mark.parametrize("command", [ |
44 | 73 | pytest.param(["speckit.test-ext.hello"], id="list"), |
45 | 74 | pytest.param({"name": "speckit.test-ext.hello"}, id="mapping"), |
@@ -722,6 +751,7 @@ def fake_install_from_zip( |
722 | 751 | patch("specify_cli.authentication.http.open_url", return_value=FakeResponse(_MINIMAL_ZIP_BYTES)), \ |
723 | 752 | patch("specify_cli.extensions._commands._safe_open_download_zip", side_effect=_open_test_download_zip), \ |
724 | 753 | patch.object(ExtensionManager, "install_from_zip", fake_install_from_zip), \ |
| 754 | + patch.object(ExtensionManager, "scaffold_config", return_value=([], [], ["test-ext-config.yml"])), \ |
725 | 755 | patch.object(ExtensionRegistry, "get", return_value={}): |
726 | 756 | result = runner.invoke( |
727 | 757 | app, |
|
0 commit comments